package common.util;

import cn.hutool.db.Db;
import cn.hutool.db.Entity;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;

import java.sql.SQLException;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CheckFirstUnit {

    /**
     * 根据用户的检索词，判断C1或RP中的信息，是否符合检索式，如果是则为第一作者单位，或通讯作者单位，若不是，则返回false。
     * 贾新志 2023.06.15
     */


    public static void saveRule(String unitTable, Map<String, String> infoAndRuleMap) throws SQLException {
        Db.use().execute("truncate table " + unitTable);  // 截断表
        Map<String, List<String>> deptAndListInfoMap = new HashMap<>();
        for (Map.Entry<String, String> entry : infoAndRuleMap.entrySet()) {
            String dept = entry.getValue();
            String info = entry.getKey();
            if (!dept.contains("|") && !isContainChinese(info) && info.length() > 4) {
                putStrListStr(deptAndListInfoMap, dept, info);
            }
        }
        for (Map.Entry<String, List<String>> entry : deptAndListInfoMap.entrySet()) {
            try {
                Db.use().insert(Entity.create(unitTable)
                        .set("dept", entry.getKey())
                        .set("info", JSONUtil.toJsonStr(entry.getValue()))
                        .set("sum", entry.getValue().size())
                );
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

    // 判断是否包含中文汉字
    public static boolean isContainChinese(String str) {
        Pattern p = Pattern.compile("[\u4e00-\u9fa5]");
        Matcher m = p.matcher(str);
        return m.find();
    }

    // 插入这类的Map：主键为String，值为List，且为String类型。
    public static void putStrListStr(Map<String, List<String>> strListStrMap, String name, String list) {
        strListStrMap.compute(name, (k, v) -> {
            if (v == null) {
                v = Collections.synchronizedList(new ArrayList<String>());
            }
            v.add(list);
            return v;
        });
    }

    // [Zhang, Zhiying; Zhang, Shuwei; Pan, Yaping] China Med Univ, Sch & Hosp Stomatol, Dept Periodont, Liaoning Prov Key Lab Oral Dis, Shenyang, Peoples R China; [Liu, Dongjuan] China Med Univ, Sch & Hosp Stomatol, Dept Emergency & Oral Med, Liaoning Prov Key Lab Oral Dis, Shenyang, Peoples R China; [Liu, Sai] China Med Univ, Sch & Hosp Stomatol, Dept Dent Mat, Liaoning Prov Key Lab Oral Dis, Shenyang, Peoples R China
    // Pan, YP (通讯作者)，China Med Univ, Sch & Hosp Stomatol, Dept Periodont, Liaoning Prov Key Lab Oral Dis, Shenyang, Peoples R China.
    // 获取C1和RP的规范后的科室信息，此为全部计算，不区分第一作者，而是整个返回一个按原来顺序的List列表。
    public static void getUnitDept(String deptTable, Map<String, String> infoAndRuleMap, String unknownTable) throws SQLException {
        List<Entity> tableData = Db.use().query("select `id`,`c_c1`,`c_rp` from " + deptTable);
        Map<String, Integer> unknownDeptAndSumMap = new HashMap<>();
        for (Entity entry : tableData) {
            String c_c1 = getStrField(entry, "c_c1");
            String c_rp = getStrField(entry, "c_rp");
            int id = getIntField(entry, "id");
            List<String> c1List = getC1(infoAndRuleMap, c_c1);
            List<String> rpList = getRP(infoAndRuleMap, c_rp);
            getUnknownDept(c1List, unknownDeptAndSumMap);
            getUnknownDept(rpList, unknownDeptAndSumMap);
            try {
                Db.use().update(
                        Entity.create().set("rp_list", JSONUtil.toJsonStr(rpList))
                                .set("c1_list", JSONUtil.toJsonStr(c1List)),
                        Entity.create(deptTable).set("id", id));
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        Db.use().execute("truncate table " + unknownTable);  // 截断表
        for (Map.Entry<String, Integer> entry : unknownDeptAndSumMap.entrySet()) {
            try {
                Db.use().insert(Entity.create(unknownTable)
                        .set("unknown_dept", entry.getKey())
                        .set("full_dept", reArgs(entry.getKey()))
                        .set("sum", entry.getValue())
                );
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

    public static void getUnknownDept(List<String> c1, Map<String, Integer> unknownDeptAndSumMap) {
        for (String s : c1) {
            if (!isContainChinese(s)) {
                unknownDeptAndSumMap.compute(s.trim(), (key, value) -> value != null ? (value + 1) : 1);
            }
        }
    }


    // 获取科室信息，方法是先循环一遍规则infoAndRuleMap，如果字符串包含规则infoAndRuleMap中的键，则存入中间结果infoAndDeptMap中
    public static String getDept(String c1, Map<String, String> infoAndRuleMap) {
        String str = reArgs(c1).toLowerCase();
        Map<String, String> infoAndDeptMap = new HashMap<>();
        for (Map.Entry<String, String> entry : infoAndRuleMap.entrySet()) {
            if (str.contains(entry.getKey())) {
                infoAndDeptMap.put(entry.getKey(), entry.getValue());
            }
        }
        int len = 0;
        String dept = c1;
        // 循环中间结果，取匹配最长的规则返回，意思是，比如，一个字符串abcd，现有规则ab和abc，则取abc的值返回。
        for (Map.Entry<String, String> entry : infoAndDeptMap.entrySet()) {
            if (entry.getKey().length() > len) {
                dept = entry.getValue();
                len = entry.getKey().length();
            }
        }
        if (dept.equals(c1)) {
            String[] split = c1.split(", ");
            for (String s : split) {
                if (s.trim().toLowerCase().startsWith("dept ")) {
                    dept = s.trim();
                    break;
                }
            }
        }
        if (dept.equals(c1)) {
            String[] split = c1.split(", ");
            for (String s : split) {
                if (s.trim().toLowerCase().startsWith("ctr ") || s.trim().toLowerCase().endsWith(" ctr")) {
                    dept = s.trim();
                    break;
                }
            }
        }
        if (dept.equals(c1)) {
            String[] split = c1.split(", ");
            for (String s : split) {
                if (s.trim().toLowerCase().contains(" key lab ") || s.trim().toLowerCase().startsWith("key lab ")) {
                    dept = s.trim();
                    break;
                }
            }
        }
        return dept;
    }

    // 读取规则表，注意，这里可以是我们自己整理的，也可以是用户自行添加上去的，都作了简写与全写的对应转换。
    public static Map<String, String> getCorpRule(String ruleTable) throws SQLException {
        Map<String, String> infoAndRuleMap = new HashMap<>();
        List<Entity> tableData = Db.use().query("select `info`,`hosp_dept` from " + ruleTable);
        for (Entity entry : tableData) {
            String info = getStrField(entry, "info").toLowerCase().trim();
            String dept = getStrField(entry, "hosp_dept");
            if (info.length() > 4 && dept.length() > 1) {
                infoAndRuleMap.put(reArgs(info), dept);
            }
        }
        return infoAndRuleMap;
    }

    // 说明，用户在添加规则时，必须区分大小写，已添加完成的规则，全部为小写。未知的也一并给读入进去了
    public static Map<Integer, Map<String, String>> getUnitRule(String unitTable, String unknownTable) throws SQLException {
        Map<Integer, Map<String, String>> infoAndRuleMapFinal = new ConcurrentHashMap<>();
        System.out.println("第二步_进方法");
        //查看所有的单位列表
        List<Entity> unit_list = Db.use().query("select * from unit_basic ; ");

        unit_list.parallelStream().forEach(i -> {
            Map<String, String> infoAndRuleMap = new ConcurrentHashMap<>();

            Integer gid = i.getInt("id");
//            System.out.println("第二步的单位___" + gid);
            List<Entity> tableData = null;
            try {
                tableData = Db.use().query("select `dept`,`info`,`gid` from " + unitTable + " where gid = " + gid);
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
            if (tableData != null) {
                for (Entity entry : tableData) {
                    String info = getStrField(entry, "info");
                    String dept = getStrField(entry, "dept");
                    List<String> infoList = JSONObject.parseArray(info, String.class);
                    for (String s : infoList) {
                        String t = reArgs(s).toLowerCase();
                        if (t.length() > 4 && dept.length() > 1) {
                            infoAndRuleMap.put(t, dept);
                        }
                    }
                }
            }

            List<Entity> unknownData = null;
            try {
                unknownData = Db.use().query("select `unknown_dept`,`name` ,`gid` from " + unknownTable + " where gid = " + gid);
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
            if (unknownTable != null) {
                for (Entity entry : unknownData) {
                    String info = getStrField(entry, "unknown_dept").trim();
                    String dept = getStrField(entry, "name").trim();
                    if (info.length() > 4 && dept.length() > 1) {
                        infoAndRuleMap.put(reArgs(info).toLowerCase(), dept);
                    }
                }
            }

            infoAndRuleMapFinal.put(gid, infoAndRuleMap);
        });


        return infoAndRuleMapFinal;
    }


    public static boolean getcy(String c1, String searchPlan) {
        List<String> result = new ArrayList<>();
        String[] split = c1.split("; \\[");
        for (int i = 1; i < split.length; i++) {
            String s = split[i];
            s = s.indexOf("] ") > 0 ? s.substring(s.indexOf("] ") + "] ".length()) : s;
            result.add(s);
        }
        for (String str : result) {
            boolean bool = CheckFirstUnit.doCheck(str, searchPlan);
            if (bool) {
                return true;
            }
        }
        return false;
    }


    // 获取C1的个个单位信息
    public static List<String> getC1(Map<String, String> infoAndRuleMap, String c1) {
        List<String> result = new ArrayList<>();
        String[] split = c1.split("; \\[");
        for (String s : split) {
            s = s.indexOf("] ") > 0 ? s.substring(s.indexOf("] ") + "] ".length()) : s;
            if (s.length() > 5) {
                result.add(getDept(s, infoAndRuleMap));
            }
        }
        return result;
    }

    // 通讯作者提取单位信息
    public static List<String> getRP(Map<String, String> infoAndRuleMap, String rpStr) {
        List<String> result = new ArrayList<>();
        if (null != rpStr && rpStr.length() > 5) {
            rpStr = rpStr.replace(" (通讯作者)，", " (corresponding author), ");
            rpStr = rpStr.indexOf(" (corresponding author), ") > 0 ? rpStr.substring(rpStr.indexOf(" (corresponding author), ")) : rpStr;
            if (rpStr.contains(" (corresponding author), ")) {
                String[] split = rpStr.split(" \\(corresponding author\\), ");
                for (String t : split) {
                    t = t.indexOf("; ") > 0 ? t.substring(0, t.indexOf("; ")) : t;
                    if (t.length() > 5) {
                        result.add(getDept(t, infoAndRuleMap));
                    }
                }
            }
        }
        return result;
    }

    public static void main(String[] args) {

    }

    public static boolean doCheck(String c1, String kw) {
        if (null == kw || kw.length() < 5 || null == c1 || c1.length() < 5) {
            return false;
        }
        kw = sameChange(kw);
        c1 = c1.toUpperCase();
        kw = reStr(kw);
        if (!kw.contains(" NOT ") && !kw.contains(" AND ") && !kw.contains(" OR ")) {
            String result = (kw.startsWith("AD=À") && kw.endsWith("Á")) ? kw.substring("AD=À".length(), kw.length() - "Á".length()) : kw;
            if (c1.contains(result) || wildcardsFalse(c1, result)) { // 2023_11_07 增加对通配符的支持
                return true;
            }
        }

        for (int i = 0; i < kw.length(); i++) {
            if (kw.contains("À") && kw.contains("Á")) {
                Matcher matcher = Pattern.compile("À([^ÀÁ]+)Á").matcher(kw);
                while (matcher.find()) {
                    String search = matcher.group(1);
                    String logic = logic(search, c1);
                    kw = kw.replace("À" + search + "Á", logic).replaceAll(" +", " ");
                }
            } else {
                break;
            }
        }
        return logic(kw, c1).contains("TRUE");
    }

//    // 检查逻辑检索式，是否符合C1，即是否是第一或通讯作者，如果是返回true，如果不是返回false
//    public static boolean doCheck(String c1, String str) {
//        if (null == str || str.length() < 5 || null == c1 || c1.length() < 5) {
//            return false;
//        }
//        // 2023_11_07 修改 解决类似这样的：AD=("qilu hosp*" same (jinan or qingdao)) OR AD= ("qi lu hosp*" same (jinan or qingdao))
////        String s1 = sameMultipleOr(str);
////        String s2 = addBracket(s1);
////        str = sameChange(s2);
////        System.out.println("s0: " + sameMultipleOr(str));
////        System.out.println("s1: " + addBracket(sameMultipleOr(str)));
////        System.out.println("s2: " + sameChange(addBracket(sameMultipleOr(str))));
////
////        System.out.println("s0: " + str);
////        System.out.println("s1: " + addBracket(str));
////        System.out.println("s2: " + sameChange(addBracket(str)));
//        str = sameChange(str);
//        c1 = c1.toUpperCase();
//        str = reStr(str);
//        if (!str.contains(" NOT ") && !str.contains(" AND ") && !str.contains(" OR ")) {
//            String result = (str.startsWith("AD=À") && str.endsWith("Á")) ? str.substring("AD=À".length(), str.length() - "Á".length()) : str;
//            if (c1.contains(result) || wildcardsFalse(c1, result)) { // 2023_11_07 增加对通配符的支持
//                return true;
//            }
//        }
////        System.out.println("S1: " + str);
//
//        for (int i = 0; i < str.length(); i++) {
//            if (str.contains("À") && str.contains("Á")) {
////                Matcher matcher = Pattern.compile("\\(([^\\(\\)]+)\\)").matcher(str);
//                Matcher matcher = Pattern.compile("À([^ÀÁ]+)Á").matcher(str);
//                while (matcher.find()) {
//                    String search = matcher.group(1);
//                    String logic = logic(search, c1);
//                    // System.out.println("search:0 " + search + " logic:" + logic + " str:" + str);
//                    str = str.replace("À" + search + "Á", logic).replaceAll(" +", " ");
//                    //  System.out.println("search:1 " + search + " logic:" + logic + " str:" + str);
//                }
//            } else {
//                break;
//            }
//        }
//
////        while (true) {
////
////        }
//        return logic(str, c1).contains("TRUE");
//    }

    //    public static String sameMultipleOr(String str) {
//        System.out.println("m1: " + str);
//        str = str.toUpperCase().replace("\"", "").trim();
//        if (str.startsWith("AD=(") && str.endsWith(")") && str.contains(" OR ") && (str.split("\\(").length == str.split("\\)").length)) {
//            Matcher m = Pattern.compile("\\([a-zA-Z0-9+\\-\\*&'. ,]+ OR [a-zA-Z0-9+\\-\\*&'. ,]+\\)").matcher(str);
//            while (m.find()) {
//                String group = m.group();
//                String g = (group.startsWith("(") && group.endsWith(")")) ? group.substring(1, group.length() - 1) : group;
//                String[] split = g.split(" OR ");
//                StringBuilder r = new StringBuilder();
//                for (String s : split) {
//                    if (s.startsWith("AD=(")) {
//                        r.append(" OR ").append(s).append(")");
//                    } else {
//                        r.append(" OR AD=(").append(s).append(")");
//                    }
//                }
//                if (r.length() > 4) {
//                    r = new StringBuilder(r.substring(4));
//                }
//                str = str.replace(group, r.toString());
//                System.out.println("mgroup: " + group);
//                System.out.println("mg: " + g);
//                System.out.println("mr: " + r);
//                System.out.println("mstr: " + str);
//            }
//        }
//        System.out.println("m2: " + str.replace("AD=(AD=(", "AD=(("));
//        return str.replace("AD=(AD=(", "AD=((");
//    }
    public static String sameMultipleOr(String str) {
        System.out.println("m1: " + str);
        String[] list = str.split("");
        for (int i = 0; i < list.length; i++) {


        }


        str = str.toUpperCase().replace("\"", "").trim();
        if (str.startsWith("AD=(") && str.endsWith(")") && str.contains(" OR ") && (str.split("\\(").length == str.split("\\)").length)) {
            Matcher m = Pattern.compile("\\([a-zA-Z0-9+\\-\\*&'. ,]+ OR [a-zA-Z0-9+\\-\\*&'. ,]+\\)").matcher(str);
            while (m.find()) {
                String group = m.group();
                String g = (group.startsWith("(") && group.endsWith(")")) ? group.substring(1, group.length() - 1) : group;
                String[] split = g.split(" OR ");
                StringBuilder r = new StringBuilder();
                for (String s : split) {
                    if (s.startsWith("AD=(")) {
                        r.append(" OR ").append(s).append(")");
                    } else {
                        r.append(" OR AD=(").append(s).append(")");
                    }
                }
                if (r.length() > 4) {
                    r = new StringBuilder(r.substring(4));
                }
                str = str.replace(group, r.toString());
                System.out.println("mgroup: " + group);
                System.out.println("mg: " + g);
                System.out.println("mr: " + r);
                System.out.println("mstr: " + str);
            }
        }
        System.out.println("m2: " + str.replace("AD=(AD=(", "AD=(("));
        return str.replace("AD=(AD=(", "AD=((");
    }

    public static String sameChange(String str) {
        // System.out.println("sameChange_input: " + str);
        String t = str.replaceAll(" +", " ").replace("（", "À").replace("）", "Á").replace(" =", "=").replace("= ", "=")
                .replace("(", "À").replace(")", "Á").replace("Á Á", "ÁÁ").replace("À À", "ÀÀ");
//        System.out.println("t: " + t);
//        System.out.println("str: " + str);
        String[] split = t.toUpperCase().replace("\"", "").trim().split("");
        int size = split.length;
        StringBuilder result = new StringBuilder();
        for (int i = 0; i < size; i++) {
//            System.out.println(" 0 " + i + " split[i]: " + split[i]);
            if (split[i].equals("A") && size > (i + 3)) {
//                System.out.println(" 1 " + i + " split[i]: " + split[i]);
                if ((split[i] + split[i + 1] + split[i + 2] + split[i + 3]).equals("AD=À")) {
//                    System.out.println(" 2 " + i + " split[i]: " + split[i]);
                    StringBuilder ad = new StringBuilder();
                    int sum = 0;
                    for (int j = i; j < size; j++) {
                        ad.append(split[j]);
                        if (split[j].equals("À")) {
                            sum++;
                        }
                        if (split[j].equals("Á")) {
                            sum--;
                            if (sum == 0) {
                                break;
                            }
                        }
                    }
                    String replace = "";
//                    System.out.println("--ad " + ad);
                    if (ad.toString().contains(" SAME ")) { // AD=ÀQILU HOSP* SAME AD=ÀJINANÁ OR AD=ÀQINGDAOÁÁ    AD=ÀQI LU HOSP* SAME AD=ÀJINANÁ OR AD=ÀQINGDAOÁ SAME ABCÁ   // AD=ÀÀSHANGHAIÁ SAME ÀJIAO TONG UNIVÁ SAME ÀSCH MEDÁÁ
                        String[] list = ad.toString().replaceAll("À+", "À").replaceAll("Á+", "Á").split(" SAME ");
//                        System.out.println("~~" + ad.toString().replaceAll("À+", "À").replaceAll("Á+", "Á"));
                        String r = "";
                        for (String s : list) {
                            if (s.trim().length() > 1) {
                                if (s.startsWith("AD=À")) {
                                    if (s.endsWith("Á")) {
                                        r += "À" + Or(s.substring("AD=À".length(), s.length() - "Á".length())) + "Á AND ";
                                    } else {
                                        r += "À" + Or(s.substring("AD=À".length())) + "Á AND ";
                                    }
                                } else if (s.startsWith("À")) {
                                    if (s.endsWith("Á")) {
                                        r += "À" + Or(s.substring("À".length(), s.length() - "Á".length())) + "Á AND ";
                                    } else {
                                        r += "À" + Or(s.substring("À".length())) + "Á AND ";
                                    }
                                } else {
                                    if (s.endsWith("Á")) {
                                        r += "À" + Or(s.substring(0, s.length() - "Á".length())) + "Á AND ";
                                    } else {
                                        r += "À" + Or(s) + "Á AND ";
                                    }
                                }
//                            System.out.println("s: " + s + " r: " + r);
                            }
                        }
                        if (r.length() > 5 && r.endsWith(" AND ")) {
                            r = r.substring(0, r.length() - " AND ".length());
                        }
                        replace = "À" + r + "Á";
                    } else {
                        replace = ad.toString();
                    }
                    result.append(replace);
                    i += ad.length() - 1;
                } else {
                    result.append(split[i]);
                }
            } else {
                result.append(split[i]);
            }
        }
//        System.out.println("sameChange_output: " + result.toString().replace("À", "(").replace("Á", ")"));
        // System.out.println("sameChange_output: " + addBracket(result.toString()).replace("À", "(").replace("Á", ")"));
        return addBracket(result.toString());
    }

    public static String Or(String str) {
//        System.out.println("or1:" + str);
        String[] split = str.replace("À", "").replace("Á", "").split(" OR ");
        String r = "";
        for (String s : split) {
            r += " OR AD=À" + s + "Á";
        }
        if (r.length() > 4) {
            r = r.substring(4);
        }
//        System.out.println("or2:" + r);
        return r;
    }

    // ad=((shanghai) same (jiao tong univ) same (sch med))->ad=((shanghai) and ad=(jiao tong univ) and ad=(sch med))
    // ad=(shanghai jiao tong univ same sch nursing) -> (ad=(shanghai jiao tong univ) and ad=(sch nursing))
    public static String sameChange1(String str) {
        String[] split = str.replace("  ", " ").replace("（", "(").replace("）", ")").replace(" =", "=").replace("= ", "=").replace("( (", "((").split("");
        int size = split.length;
        StringBuilder result = new StringBuilder();
        for (int i = 0; i < size; i++) {
            if (split[i].toLowerCase().equals("a") && size > (i + 2)) {
                if ((split[i] + split[i + 1] + split[i + 2] + split[i + 3]).toLowerCase().equals("ad=(")) {
                    StringBuilder ad = new StringBuilder();
                    int sum = 0;
                    for (int j = i; j < size; j++) {
                        ad.append(split[j]);
                        if (split[j].equals("(")) {
                            sum++;
                        }
                        if (split[j].equals(")")) {
                            sum--;
                            if (sum == 0) {
                                break;
                            }
                        }
                    }
                    String replace = "";
                    if (ad.toString().toLowerCase().contains(") same (")) {
                        replace = ad.toString().replace("AD=((", "(AD=(").replace(") SAME (", ") AND AD=(").replace("ad=((", "(ad=(").replace(") same (", ") and ad=(");
                    } else if (ad.toString().toLowerCase().contains(" same ")) {
                        replace = ad.toString().replace("AD=(", "(AD=(").replace(" SAME ", ") AND AD=(").replace("ad=(", "(ad=(").replace(" same ", ") and ad=(") + ")";
                    } else {
                        replace = ad.toString();
                    }
                    result.append(replace);
                    i += ad.length() - 1;
                } else {
                    result.append(split[i]);
                }
            } else {
                result.append(split[i]);
            }
        }
        return result.toString();
    }

    // 将检索式的括号，修改为特殊的字符串：À->左引号或左括号  Á->右引号或右括号
//    public static String changeStr(String str) {
//        String[] split = str.split("");
//        StringBuilder result = new StringBuilder();
//        boolean bool = false;
//        for (int i = 0; i < split.length; i++) {
//            String t = split[i];
//            if (t.equals("(") && split.length > i + 1 && i > 2 && split[i - 1].equals("=") && split[i - 2].equals("D") && split[i - 3].equals("A")) {
//                result.append("À");
//                bool = true;
//                continue;
//            }
//            if (bool) {
//                if (t.equals(")")) {
//                    result.append("Á");
//                    bool = false;
//                    continue;
//                }
//            }
//            result.append(t);
//        }
//        if (bool) {
//            result.append("Á");
//        }
//        // 以下为2023_11_07修改 AD=(QILU HOSP* SAME AD=(JI NAN) OR AD=(QINGDAO) OR AD=(JINAN) OR AD=(QING DAO)) OR AD=(QI LU HOSP* SAME AD=(JINAN) OR AD=(QINGDAO)) -> AD=ÀQILU HOSP* SAME AD=ÀJI NANÁ OR AD=ÀQINGDAOÁ OR AD=ÀJINANÁ OR AD=ÀQING DAOÁÁ OR AD=ÀQI LU HOSP* SAME AD=ÀJINANÁ OR AD=ÀQINGDAOÁÁ
//        String r = result.toString();
//        int l1 = r.contains("À") ? r.split("À").length : 0;
//        int l2 = r.contains("Á") ? r.split("Á").length : 0;
//        int r1 = r.contains("(") ? r.split("\\(").length : 0;
//        int r2 = r.contains(")") ? r.split("\\)").length : 0;
//        if (l1 != l2 && r1 == 0 && r2 > 0 && l1 == (l2 + r2)) {
//            r = r.replace(")", "Á");
//        }
//        return r;
//    }

    // 统一规范检索式，要求所有的检索词均被括号括起来，如果没有括号的，给加上。加上后，再把检索式的括号给改成引号引起来，这里的引号使用特殊的字符串：À->左引号或左括号  Á->右引号或右括号
    public static String addBracket(String str) {
//        System.out.println("addBracket_input: " + str);
        str = str.toUpperCase().replaceAll(" +", " ").replace(" )", ")").replace("( ", "(").replace(" =", "=").replace("= ", "=").replace(")", "Á").replace("(", "À").trim();
        String[] split = str.split("");
        StringBuilder result = new StringBuilder();
        boolean bool = false;
        for (int i = 0; i < split.length; i++) {
            String t = split[i];
            if (t.equals("=") && split.length > i + 1 && i > 1 && !split[i + 1].equals("À") && split[i - 1].equals("D") && split[i - 2].equals("A")) {
                result.append(t);
                result.append("À");
                bool = true;
                continue;
            }
            if (bool) {
                if (t.equals(" ") || t.equals("Á")) {
                    result.append("Á");
                    bool = false;
                }
            }
            result.append(t);
        }
        if (bool) {
            result.append("Á");
        }
//        System.out.println("addBracket_output: " + changeStr(result.toString()));
//        return changeStr(result.toString());
        return result.toString();
    }

    public static boolean wildcardsFalse(String c1, String result) {
        if (result.contains("*")) {
            String w = result.replace("*", ".*?"); // Liao*Cheng People* Hosp -> LIAO.*?CHENG PEOPLE.*? HOSP
            Matcher matcher = Pattern.compile(w).matcher(c1);  // c1:LIAO CHENG PEOPLES HOSP, LIAOCHENG 252002, SHANDONG, PEOPLES R CHINA.
            return matcher.find();
        }
        if (result.contains("?")) {
            String w = result.replace("?", ".?"); // 0到1个
            Matcher matcher = Pattern.compile(w).matcher(c1);  //
            return matcher.find();
        }
        return false;
    }

    // 这个方法与上面的不一样，上面的默认返回false，用于与||一起使用。这个默认返回true，用于与&&一起使用。
    public static boolean wildcards(String c1, String result) {
        if (result.contains("*")) {
            String w = result.replace("*", ".*?"); // Liao*Cheng People* Hosp -> LIAO.*?CHENG PEOPLE.*? HOSP
            Matcher matcher = Pattern.compile(w).matcher(c1);  // c1:LIAO CHENG PEOPLES HOSP, LIAOCHENG 252002, SHANDONG, PEOPLES R CHINA.
            return matcher.find();
        }
        if (result.contains("?")) {
            String w = result.replace("?", ".?"); // 0到1个
            Matcher matcher = Pattern.compile(w).matcher(c1);  //
            return matcher.find();
        }
        return true;
    }

    // À->左引号或左括号  Á->右引号或右括号，检索式支持的字符包含a-zA-Z0-9+-*&'. ,，本方法使用for，而不是使用while，主要是担心死循环。
    public static String logic(String str, String c1) {
        if (null == str || null == c1) {
            return "⬇FALSE";
        }
        str = reStr(str);
        if (!str.contains(" NOT ") && !str.contains(" AND ") && !str.contains(" OR ")) {
            String result = (str.startsWith("AD=À") && str.endsWith("Á")) ? str.substring("AD=À".length(), str.length() - "Á".length()) : str;
            if (c1.contains(result) || wildcardsFalse(c1, result)) { // 2023_11_07 增加对通配符的支持
                return "⬇TRUE";
            }
        }

        if (str.trim().equals("⬇TRUE")) {
            return "⬇TRUE";
        }
        if (str.trim().equals("⬇FALSE")) {
            return "⬇FALSE";
        }

        // 逻辑关系NOT，一般为排除检索式（AD=），但也有逻辑关系之间的NOT运算，最后还有排除逻辑关系的，这两分为两部分，优先处理前两种情况。
        for (int i = 0; i < str.length(); i++) {
            if (!str.contains(" NOT ")) {
                break;
            }
            if (str.indexOf(" NOT AD=À") > 0) {
                String temp = str.substring(str.indexOf(" NOT AD=À"));
                String aa = temp.substring(" NOT AD=À".length(), temp.indexOf("Á")); // Taiwan,
                if (temp.indexOf("Á") > 0) {
                    String bb = temp.substring(0, temp.indexOf("Á") + "Á".length()); //  NOT AD=(Taiwan,)
                    if (c1.contains(aa) || wildcardsFalse(c1, aa)) { // 2023_11_07 增加对通配符的支持
                        return "⬇FALSE";
                    } else {
                        str = reStr(str.replace(bb, " ⬇TRUE ")); // AD=(China Med Univ) OR AD=(China Medical University) AND AD=(HOSP 1,)
                    }
                }
            }
            if (str.contains("⬇TRUE NOT ⬇FALSE")) {
                str = reStr(str.substring(0, str.indexOf("⬇TRUE NOT ⬇FALSE")) + "⬇TRUE" + str.substring(str.indexOf("⬇TRUE NOT ⬇FALSE") + "⬇TRUE NOT ⬇FALSE".length()));
            }
            if (str.contains("⬇TRUE NOT ⬇TRUE")) {
                str = reStr(str.substring(0, str.indexOf("⬇TRUE NOT ⬇TRUE")) + "⬇FALSE" + str.substring(str.indexOf("⬇TRUE NOT ⬇TRUE") + "⬇TRUE NOT ⬇TRUE".length()));
            }
            if (str.contains("⬇FALSE NOT ⬇FALSE")) {
                str = reStr(str.substring(0, str.indexOf("⬇FALSE NOT ⬇FALSE")) + "⬇FALSE" + str.substring(str.indexOf("⬇FALSE NOT ⬇FALSE") + "⬇FALSE NOT ⬇FALSE".length()));
            }
            if (str.contains("⬇FALSE NOT ⬇TRUE")) {
                str = reStr(str.substring(0, str.indexOf("⬇FALSE NOT ⬇TRUE")) + "⬇FALSE" + str.substring(str.indexOf("⬇FALSE NOT ⬇TRUE") + "⬇FALSE NOT ⬇TRUE".length()));
            }
//            if (str.contains("AD=⬇TRUE NOT AD=⬇FALSE")) {
//                str = reStr(str.substring(0, str.indexOf("AD=⬇TRUE NOT AD=⬇FALSE")) + "⬇TRUE" + str.substring(str.indexOf("AD=⬇TRUE NOT AD=⬇FALSE") + "AD=⬇TRUE NOT AD=⬇FALSE".length()));
//            }
//            if (str.contains("AD=⬇TRUE NOT AD=⬇TRUE")) {
//                str = reStr(str.substring(0, str.indexOf("AD=⬇TRUE NOT AD=⬇TRUE")) + "⬇FALSE" + str.substring(str.indexOf("AD=⬇TRUE NOT AD=⬇TRUE") + "AD=⬇TRUE NOT AD=⬇TRUE".length()));
//            }
//            if (str.contains("AD=⬇FALSE NOT AD=⬇FALSE")) {
//                str = reStr(str.substring(0, str.indexOf("AD=⬇FALSE NOT AD=⬇FALSE")) + "⬇FALSE" + str.substring(str.indexOf("AD=⬇FALSE NOT AD=⬇FALSE") + "AD=⬇FALSE NOT AD=⬇FALSE".length()));
//            }
//            if (str.contains("AD=⬇FALSE NOT AD=⬇TRUE")) {
//                str = reStr(str.substring(0, str.indexOf("AD=⬇FALSE NOT AD=⬇TRUE")) + "⬇FALSE" + str.substring(str.indexOf("AD=⬇FALSE NOT AD=⬇TRUE") + "AD=⬇FALSE NOT AD=⬇TRUE".length()));
//            }
        }

        for (int i = 0; i < str.length(); i++) {
            if (!str.contains(" NOT ")) {
                break;
            }
            if (str.contains(" NOT ⬇FALSE")) {
                str = reStr(str.substring(0, str.indexOf(" NOT ⬇FALSE")) + "⬇TRUE" + str.substring(str.indexOf(" NOT ⬇FALSE") + " NOT ⬇FALSE".length()));
            }
            if (str.contains(" NOT ⬇TRUE")) {
                str = reStr(str.substring(0, str.indexOf(" NOT ⬇TRUE")) + "⬇FALSE" + str.substring(str.indexOf(" NOT ⬇TRUE") + " NOT ⬇TRUE".length()));
            }
        }

        if (str.trim().equals("⬇TRUE")) {
            return "⬇TRUE";
        }
        if (str.trim().equals("⬇FALSE")) {
            return "⬇FALSE";
        }

        // 逻辑关系AND，有多种形式，有检索式（AD=）与检索式的，也有检索式与逻辑关系的，也有逻辑关系与逻辑关系的
        for (int i = 0; i < str.length(); i++) {
            str = str.toUpperCase().replaceAll(" +", " ").replace(" )", ")").replace("( ", "(").replace(" =", "=").replace("= ", "=");
            if (!str.contains(" AND ")) {
                break;
            }
            for (int j = 0; j < str.length(); j++) {
                Matcher m0 = Pattern.compile("(AD=À[a-zA-Z0-9+\\-*&'. ,]+Á AND AD=À.+?Á)").matcher(str);
                if (m0.find()) {
                    String search = m0.group(1);
                    String aa = search.substring(search.indexOf("À") + "À".length(), search.indexOf("Á"));
                    String bb = search.substring(search.lastIndexOf("À") + "À".length(), search.lastIndexOf("Á"));
                    str = (c1.contains(aa) && c1.contains(bb) && wildcards(c1, aa) && wildcards(c1, bb)) ? reStr(str.replace(search, " ⬇TRUE ")) : reStr(str.replace(search, " ⬇FALSE ")); // 2023_11_07 增加对通配符的支持
                } else {
                    break;
                }
            }
            for (int j = 0; j < str.length(); j++) {
                Matcher m1 = Pattern.compile("(AD=À[a-zA-Z0-9+\\-*&'. ,]+Á AND ⬇TRUE)").matcher(str);
                if (m1.find()) {
                    String search = m1.group(1);
                    String aa = search.substring(search.indexOf("À") + "À".length(), search.indexOf("Á"));
                    str = (c1.contains(aa) && wildcards(c1, aa)) ? reStr(str.replace(search, " ⬇TRUE ")) : reStr(str.replace(search, " ⬇FALSE ")); // 2023_11_07 增加对通配符的支持
                } else {
                    break;
                }
            }
            for (int j = 0; j < str.length(); j++) {
                Matcher m3 = Pattern.compile("(AD=À[a-zA-Z0-9+\\-*&'. ,]+Á AND ⬇FALSE)").matcher(str);
                if (m3.find()) {
                    String search = m3.group(1);
                    str = reStr(str.replace(search, " ⬇FALSE "));
                } else {
                    break;
                }
            }
            for (int j = 0; j < str.length(); j++) {
                Matcher m2 = Pattern.compile("(⬇TRUE AND AD=À[a-zA-Z0-9+\\-*&'. ,]+Á)").matcher(str);
                if (m2.find()) {
                    String search = m2.group(1);
                    String aa = search.substring(search.indexOf("À") + "À".length(), search.indexOf("Á"));
                    str = (c1.contains(aa) && wildcards(c1, aa)) ? reStr(str.replace(search, " ⬇TRUE ")) : reStr(str.replace(search, " ⬇FALSE ")); // 2023_11_07 增加对通配符的支持
                } else {
                    break;
                }
            }
            for (int j = 0; j < str.length(); j++) {
                Matcher m4 = Pattern.compile("(⬇FALSE AND AD=À[a-zA-Z0-9+\\-*&'. ,]+Á)").matcher(str);
                if (m4.find()) {
                    String search = m4.group(1);
                    str = reStr(str.replace(search, " ⬇FALSE "));
                } else {
                    break;
                }
            }
            for (int j = 0; j < str.length(); j++) {
                if (str.contains("⬇FALSE AND ⬇TRUE")) {
                    str = reStr(str.substring(0, str.indexOf("⬇FALSE AND ⬇TRUE")) + "⬇FALSE" + str.substring(str.indexOf("⬇FALSE AND ⬇TRUE") + "⬇FALSE AND ⬇TRUE".length()));
                } else {
                    break;
                }
            }
            for (int j = 0; j < str.length(); j++) {
                if (str.contains("⬇TRUE AND ⬇FALSE")) {
                    str = reStr(str.substring(0, str.indexOf("⬇TRUE AND ⬇FALSE")) + "⬇FALSE" + str.substring(str.indexOf("⬇TRUE AND ⬇FALSE") + "⬇TRUE AND ⬇FALSE".length()));
                } else {
                    break;
                }
            }
            for (int j = 0; j < str.length(); j++) {
                if (str.contains("⬇TRUE AND ⬇TRUE")) {
                    str = reStr(str.substring(0, str.indexOf("⬇TRUE AND ⬇TRUE")) + "⬇TRUE" + str.substring(str.indexOf("⬇TRUE AND ⬇TRUE") + "⬇TRUE AND ⬇TRUE".length()));
                } else {
                    break;
                }
            }
            for (int j = 0; j < str.length(); j++) {
                if (str.contains("⬇FALSE AND ⬇FALSE")) {
                    str = reStr(str.substring(0, str.indexOf("⬇FALSE AND ⬇FALSE")) + "⬇FALSE" + str.substring(str.indexOf("⬇FALSE AND ⬇FALSE") + "⬇FALSE AND ⬇FALSE".length()));
                } else {
                    break;
                }
            }
//            for (int j = 0; j < str.length(); j++) {
//                if (str.contains("AD=⬇FALSE AND AD=⬇TRUE")) {
//                    str = reStr(str.substring(0, str.indexOf("AD=⬇FALSE AND AD=⬇TRUE")) + "⬇FALSE" + str.substring(str.indexOf("AD=⬇FALSE AND AD=⬇TRUE") + "AD=⬇FALSE AND AD=⬇TRUE".length()));
//                } else {
//                    break;
//                }
//            }
//            for (int j = 0; j < str.length(); j++) {
//                if (str.contains("AD=⬇TRUE AND AD=⬇FALSE")) {
//                    str = reStr(str.substring(0, str.indexOf("AD=⬇TRUE AND AD=⬇FALSE")) + "⬇FALSE" + str.substring(str.indexOf("AD=⬇TRUE AND AD=⬇FALSE") + "AD=⬇TRUE AND AD=⬇FALSE".length()));
//                } else {
//                    break;
//                }
//            }
//            for (int j = 0; j < str.length(); j++) {
//                if (str.contains("AD=⬇TRUE AND AD=⬇TRUE")) {
//                    str = reStr(str.substring(0, str.indexOf("AD=⬇TRUE AND AD=⬇TRUE")) + "⬇TRUE" + str.substring(str.indexOf("AD=⬇TRUE AND AD=⬇TRUE") + "AD=⬇TRUE AND AD=⬇TRUE".length()));
//                } else {
//                    break;
//                }
//            }
//            for (int j = 0; j < str.length(); j++) {
//                if (str.contains("AD=⬇FALSE AND AD=⬇FALSE")) {
//                    str = reStr(str.substring(0, str.indexOf("AD=⬇FALSE AND AD=⬇FALSE")) + "⬇FALSE" + str.substring(str.indexOf("AD=⬇FALSE AND AD=⬇FALSE") + "AD=⬇FALSE AND AD=⬇FALSE".length()));
//                } else {
//                    break;
//                }
//            }
        }

        // 最后只留下逻辑关系为OR的了，如果包含有任一个TRUE即可返回TRUE，如果等于FALSE也直接返回FALSE，如果还是检索式（AD=），则取括号内的各个检索式，若任何一个包含，则返回TRUE，若一个也不包含，则返回FALSE。
        if (str.contains("⬇TRUE")) {
            return "⬇TRUE";
        } else if (str.trim().equals("⬇FALSE")) {
            return "⬇FALSE";
        } else {
            Matcher matcher = Pattern.compile("À([^ÀÁ]+)Á").matcher(str);
            while (matcher.find()) {
                String search = matcher.group(1);
                if (c1.contains(search) || wildcardsFalse(c1, search)) { // 2023_11_07 增加对通配符的支持
                    return "⬇TRUE";
                }
            }

        }
        return "⬇FALSE";
    }

    public static String reStr(String str) {
        return str.replaceAll(" +", " ").replace("À ", "À").replace(" Á", "Á").replace(" )", ")").replace("( ", "(").replace(" =", "=")
                .replace("= ", "=").replace("AD=⬇FALSE", "⬇FALSE").replace("AD=⬇TRUE", "⬇TRUE").trim();
    }


    public static String reArgsFront(String str) {
        if (null == str || str.length() < 1) {
            return "";
        }
        str = str.replaceAll("^Abt([.,; ])", "Abteilung$1")
                .replaceAll("^Academy([.,; ])", "Academy$1")
                .replaceAll("^Acad([.,; ])", "Academy$1")
                .replaceAll("^Accid([.,; ])", "Accident$1")
                .replaceAll("^Administration([.,; ])", "Administration$1")
                .replaceAll("^Adm([.,; ])", "Administration$1")
                .replaceAll("^Adv([.,; ])", "Advance(d)$1")
                .replaceAll("^Aerosp([.,; ])", "Aerospace$1")
                .replaceAll("^Agcy([.,; ])", "Agency$1")
                .replaceAll("^Agriculture([.,; ])", "Agricultural$1")
                .replaceAll("^Agr([.,; ])", "Agricultural$1")
                .replaceAll("^Akad([.,; ])", "Accident$1")
                .replaceAll("^Amer([.,; ])", "America(n)$1")
                .replaceAll("^Anal([.,; ])", "Analysis$1")
                .replaceAll("^Anatomie([.,; ])", "Anatomia$1")
                .replaceAll("^Anatomy([.,; ])", "Anatomia$1")
                .replaceAll("^Anat([.,; ])", "Anatomia$1")
                .replaceAll("^Angew([.,; ])", "Angewandte$1")
                .replaceAll("^Anim([.,; ])", "Animal$1")
                .replaceAll("^Antigua & Barbu([.,; ])", "Antigua & Barbuda$1")
                .replaceAll("^Apparat([.,; ])", "Apparatus$1")
                .replaceAll("^Appl([.,; ])", "Applied$1")
                .replaceAll("^Arthrit([.,; ])", "Arthritis$1")
                .replaceAll("^Assoc([.,; ])", "Association$1")
                .replaceAll("^Augenklin([.,; ])", "Augenklinik$1")
                .replaceAll("^Ave([.,; ])", "Avenue$1")
                .replaceAll("^Behavior([.,; ])", "Behavior$1")
                .replaceAll("^Behaviour([.,; ])", "Behavior$1")
                .replaceAll("^Behav([.,; ])", "Behavior$1")
                .replaceAll("^Biochem([.,; ])", "Biochemistry$1")
                .replaceAll("^Biologie([.,; ])", "Biologie$1")
                .replaceAll("^Biology([.,; ])", "Biologie$1")
                .replaceAll("^Biol([.,; ])", "Biologie$1")
                .replaceAll("^Bldg([.,; ])", "Building$1")
                .replaceAll("^Blvd([.,; ])", "Boulevard$1")
                .replaceAll("^Bosnia & Herceg([.,; ])", "Bosnia & Hercegovina$1")
                .replaceAll("^Botanic([.,; ])", "Botanical$1")
                .replaceAll("^Botany([.,; ])", "Botanical$1")
                .replaceAll("^Bot([.,; ])", "Botanical$1")
                .replaceAll("^Bros([.,; ])", "Brothers$1")
                .replaceAll("^Bur([.,; ])", "Bureau$1")
                .replaceAll("^Canc([.,; ])", "Cancer$1")
                .replaceAll("^Cent Afr Republ([.,; ])", "Central African Republic$1")
                .replaceAll("^Cent([.,; ])", "Central$1")
                .replaceAll("^Chemistry([.,; ])", "Chemistry$1")
                .replaceAll("^Chem([.,; ])", "Chemistry$1")
                .replaceAll("^Chim([.,; ])", "Chemistry$1")
                .replaceAll("^Chirurg([.,; ])", "Chirurgie$1")
                .replaceAll("^Cient([.,; ])", "Cientificas$1")
                .replaceAll("^Clinic([.,; ])", "Clinical$1")
                .replaceAll("^Clin([.,; ])", "Clinical$1")
                .replaceAll("^Coll([.,; ])", "College$1")
                .replaceAll("^Commun([.,; ])", "Communication$1")
                .replaceAll("^Comm([.,; ])", "Committee$1")
                .replaceAll("^Computer([.,; ])", "Computer$1")
                .replaceAll("^Comp([.,; ])", "Computer$1")
                .replaceAll("^Com([.,; ])", "Comite$1")
                .replaceAll("^Conf([.,; ])", "Conference$1")
                .replaceAll("^Corporation([.,; ])", "Corporate$1")
                .replaceAll("^Corp([.,; ])", "Corporation$1")
                .replaceAll("^Co([.,; ])", "Company$1")
                .replaceAll("^Cpds([.,; ])", "Compounds$1")
                .replaceAll("^Ctr([.,; ])", "Center$1")
                .replaceAll("^Cty([.,; ])", "County$1")
                .replaceAll("^Cytologie([.,; ])", "Cytologie$1")
                .replaceAll("^Cytology([.,; ])", "Cytologie$1")
                .replaceAll("^Cytol([.,; ])", "Cytologie$1")
                .replaceAll("^Def([.,; ])", "Defence or Defense$1")
                .replaceAll("^Dental([.,; ])", "Dentistry$1")
                .replaceAll("^Dent([.,; ])", "Dentistry$1")
                .replaceAll("^Dept([.,; ])", "Department$1")
                .replaceAll("^Deutschen([.,; ])", "Deutschen$1")
                .replaceAll("^Deutscher([.,; ])", "Deutschen$1")
                .replaceAll("^Deutsches([.,; ])", "Deutsches$1")
                .replaceAll("^Deutsche([.,; ])", "Deutsches$1")
                .replaceAll("^Deutsch([.,; ])", "Deutsches$1")
                .replaceAll("^Development([.,; ])", "Development$1")
                .replaceAll("^Dev([.,; ])", "Development$1")
                .replaceAll("^Diabet([.,; ])", "Diabet$1")
                .replaceAll("^Diag([.,; ])", "Diagnosis$1")
                .replaceAll("^Disease([.,; ])", "Diseases$1")
                .replaceAll("^Dist([.,; ])", "District$1")
                .replaceAll("^Dis([.,; ])", "Diseases$1")
                .replaceAll("^Div([.,; ])", "Division$1")
                .replaceAll("^Dominican Rep([.,; ])", "Dominican Republic$1")
                .replaceAll("^Dr([.,; ])", "Drive$1")
                .replaceAll("^Econ([.,; ])", "Economy$1")
                .replaceAll("^Education([.,; ])", "Education$1")
                .replaceAll("^Educ([.,; ])", "Education$1")
                .replaceAll("^EEG([.,; ])", "Electroencephalographic$1")
                .replaceAll("^Egyet([.,; ])", "Egyetem$1")
                .replaceAll("^Electrical([.,; ])", "Electrical$1")
                .replaceAll("^Electricity([.,; ])", "Electrical$1")
                .replaceAll("^Electric([.,; ])", "Electrical$1")
                .replaceAll("^Electroencephalographic([.,; ])", "Electroencephalography$1")
                .replaceAll("^Electronic([.,; ])", "Electrical$1")
                .replaceAll("^Elect([.,; ])", "Electrical$1")
                .replaceAll("^Elektrische([.,; ])", "Electrical$1")
                .replaceAll("^Elektrizitat([.,; ])", "Electrical$1")
                .replaceAll("^Elektronic([.,; ])", "Electrical$1")
                .replaceAll("^Elekt([.,; ])", "Electrical$1")
                .replaceAll("^Engineering([.,; ])", "Electrical$1")
                .replaceAll("^Engn([.,; ])", "Electrical$1")
                .replaceAll("^Environment([.,; ])", "Environment$1")
                .replaceAll("^Environm([.,; ])", "Environment$1")
                .replaceAll("^Equat Guinea([.,; ])", "Equatorial Guinea$1")
                .replaceAll("^Establishment([.,; ])", "Etablissement$1")
                .replaceAll("^Estab([.,; ])", "Establishment$1")
                .replaceAll("^Estab([.,; ])", "Etablissement$1")
                .replaceAll("^Etab([.,; ])", "Etablissement$1")
                .replaceAll("^Etud([.,; ])", "Étude$1")
                .replaceAll("^Experiment([.,; ])", "Experiment$1")
                .replaceAll("^Expt([.,; ])", "Experiment$1")
                .replaceAll("^E([.,; ])", "East$1")
                .replaceAll("^Fac([.,; ])", "Faculty$1")
                .replaceAll("^Fak([.,; ])", "Fakultat$1")
                .replaceAll("^Farm([.,; ])", "Farmacia$1")
                .replaceAll("^Fdn([.,; ])", "Foundation$1")
                .replaceAll("^Fed([.,; ])", "Federal$1")
                .replaceAll("^Fis([.,; ])", "Fisica$1")
                .replaceAll("^Forsch([.,; ])", "Forschung$1")
                .replaceAll("^Foundation([.,; ])", "Fundacion$1")
                .replaceAll("^Fr Austr Lands([.,; ])", "French Austral Lands$1")
                .replaceAll("^Fr Polynesia([.,; ])", "French Polynesia$1")
                .replaceAll("^Ft([.,; ])", "Fort$1")
                .replaceAll("^Fys([.,; ])", "Fysica$1")
                .replaceAll("^Gen([.,; ])", "General$1")
                .replaceAll("^Geol([.,; ])", "Geology$1")
                .replaceAll("^Gesell([.,; ])", "Gesellschaft$1")
                .replaceAll("^Govt([.,; ])", "Government$1")
                .replaceAll("^Grad([.,; ])", "Graduate$1")
                .replaceAll("^Group([.,; ])", "Gruppe$1")
                .replaceAll("^Grp([.,; ])", "Group$1")
                .replaceAll("^Hgsk([.,; ])", "Hogeskole$1")
                .replaceAll("^Historic([.,; ])", "Historical$1")
                .replaceAll("^History([.,; ])", "Historical$1")
                .replaceAll("^Hist([.,; ])", "Historical$1")
                .replaceAll("^Hlth([.,; ])", "Health$1")
                .replaceAll("^Hop([.,; ])", "Hospital$1")
                .replaceAll("^Horticulture([.,; ])", "Horticultural$1")
                .replaceAll("^Hort([.,; ])", "Horticultural$1")
                .replaceAll("^Hosp([.,; ])", "Hospital$1")
                .replaceAll("^Hsch([.,; ])", "Hochschule$1")
                .replaceAll("^Hts([.,; ])", "Heights$1")
                .replaceAll("^Husb([.,; ])", "Husbandry$1")
                .replaceAll("^Hyg([.,; ])", "Hygiene$1")
                .replaceAll("^Immunol([.,; ])", "Immunology$1")
                .replaceAll("^Inc([.,; ])", "Incorporated$1")
                .replaceAll("^Industry([.,; ])", "Industrial$1")
                .replaceAll("^Ind([.,; ])", "Industrial$1")
                .replaceAll("^Ind([.,; ])", "Industry$1")
                .replaceAll("^Infect([.,; ])", "Infectious$1")
                .replaceAll("^Infirm([.,; ])", "Infirmary$1")
                .replaceAll("^Ingegneria([.,; ])", "Ingenieria$1")
                .replaceAll("^Ingenieria([.,; ])", "Ingenieria$1")
                .replaceAll("^Ingn([.,; ])", "Ingenieria$1")
                .replaceAll("^Institute([.,; ])", "Institutional$1")
                .replaceAll("^Institute([.,; ])", "Ist$1")
                .replaceAll("^Inst([.,; ])", "Institute$1")
                .replaceAll("^Intro([.,; ])", "Introduction$1")
                .replaceAll("^Int([.,; ])", "International$1")
                .replaceAll("^Investigation([.,; ])", "Investigational$1")
                .replaceAll("^Invest([.,; ])", "Investigational$1")
                .replaceAll("^Isit([.,; ])", "Institutional$1")
                .replaceAll("^Isl([.,; ])", "Island$1")
                .replaceAll("^Istituto([.,; ])", "Institutional$1")
                .replaceAll("^Jr([.,; ])", "Junior$1")
                .replaceAll("^Kardiol([.,; ])", "Kardiologie$1")
                .replaceAll("^Kem([.,; ])", "Kemiai$1")
                .replaceAll("^Klin([.,; ])", "Klinik$1")
                .replaceAll("^Konf([.,; ])", "Konference$1")
                .replaceAll("^Laboratory([.,; ])", "Laboratories$1")
                .replaceAll("^Labs([.,; ])", "Laboratories$1")
                .replaceAll("^Lab([.,; ])", "Laboratories$1")
                .replaceAll("^Lect([.,; ])", "Lecture$1")
                .replaceAll("^Lib([.,; ])", "Library$1")
                .replaceAll("^Ltd([.,; ])", "Limited$1")
                .replaceAll("^Malad([.,; ])", "Maladies$1")
                .replaceAll("^Malagasy Republ([.,; ])", "Malagasy Republic$1")
                .replaceAll("^Matemat([.,; ])", "Matematicky$1")
                .replaceAll("^Mathematics([.,; ])", "Mathematical$1")
                .replaceAll("^Math([.,; ])", "Mathematics$1")
                .replaceAll("^Mat([.,; ])", "Material$1")
                .replaceAll("^Mechanical([.,; ])", "Mechanical$1")
                .replaceAll("^Mechanics([.,; ])", "Mechanical$1")
                .replaceAll("^Mech([.,; ])", "Mechanical$1")
                .replaceAll("^Medical([.,; ])", "Medicinal$1")
                .replaceAll("^Medicinal([.,; ])", "Medicinal$1")
                .replaceAll("^Medicine([.,; ])", "Medicinal$1")
                .replaceAll("^Meditskkaya([.,; ])", "Medizin$1")
                .replaceAll("^Med([.,; ])", "Medical$1")
                .replaceAll("^Mem([.,; ])", "Memorial$1")
                .replaceAll("^Metabolic([.,; ])", "Metabolism$1")
                .replaceAll("^Metab([.,; ])", "Metabolic$1")
                .replaceAll("^Metallurgy([.,; ])", "Metabolic$1")
                .replaceAll("^Metal([.,; ])", "Metabolic$1")
                .replaceAll("^Met([.,; ])", "Metallurgical$1")
                .replaceAll("^Mfg([.,; ])", "Manufacturing$1")
                .replaceAll("^Mil([.,; ])", "Military$1")
                .replaceAll("^Minist([.,; ])", "Ministry$1")
                .replaceAll("^Min([.,; ])", "Mining$1")
                .replaceAll("^Mkt([.,; ])", "Mining$1")
                .replaceAll("^Molecule([.,; ])", "Molekular$1")
                .replaceAll("^Mol([.,; ])", "Molecular$1")
                .replaceAll("^Mongol Peo Rep([.,; ])", "Mongolian People's Republic$1")
                .replaceAll("^Mount([.,; ])", "Mountain$1")
                .replaceAll("^Mt([.,; ])", "Mountain$1")
                .replaceAll("^Nacional([.,; ])", "Nacional$1")
                .replaceAll("^National([.,; ])", "Nacional$1")
                .replaceAll("^Natl([.,; ])", "Nacional$1")
                .replaceAll("^Nature([.,; ])", "Nacional$1")
                .replaceAll("^Nat([.,; ])", "Nature$1")
                .replaceAll("^Navigation([.,; ])", "Navigational$1")
                .replaceAll("^Nav([.,; ])", "Navigational$1")
                .replaceAll("^Nazionale([.,; ])", "Nazionale$1")
                .replaceAll("^Neth Antilles([.,; ])", "Netherlands Antilles$1")
                .replaceAll("^NE([.,; ])", "Northeast$1")
                .replaceAll("^North Ireland([.,; ])", "Northern Ireland$1")
                .replaceAll("^Northeast([.,; ])", "Northeastern$1")
                .replaceAll("^Northwest([.,; ])", "Northwestern$1")
                .replaceAll("^No([.,; ])", "Northern$1")
                .replaceAll("^Nucl([.,; ])", "Nuclear$1")
                .replaceAll("^Nukl([.,; ])", "Nuklear$1")
                .replaceAll("^Nutr([.,; ])", "Nutrition$1")
                .replaceAll("^NW([.,; ])", "Northwest$1")
                .replaceAll("^N([.,; ])", "North$1")
                .replaceAll("^Observ([.,; ])", "Observatory$1")
                .replaceAll("^Obstet([.,; ])", "Obstetrics$1")
                .replaceAll("^Off([.,; ])", "Office$1")
                .replaceAll("^Organization([.,; ])", "Organizational$1")
                .replaceAll("^Org([.,; ])", "Organization$1")
                .replaceAll("^Osped([.,; ])", "Ospedale$1")
                .replaceAll("^Paediatric([.,; ])", "Paediatric$1")
                .replaceAll("^Paediat([.,; ])", "Paediat$1")
                .replaceAll("^Papua N Guinea([.,; ])", "Papua New Guinea$1")
                .replaceAll("^Pediatric([.,; ])", "Pediatrics$1")
                .replaceAll("^Peoples R China([.,; ])", "People's Republic of China$1")
                .replaceAll("^Petr([.,; ])", "Petroleum$1")
                .replaceAll("^Pharm([.,; ])", "Pharmacy$1")
                .replaceAll("^Phys([.,; ])", "Physical$1")
                .replaceAll("^Pkwy([.,; ])", "Parkway$1")
                .replaceAll("^Pk([.,; ])", "Park$1")
                .replaceAll("^Place([.,; ])", "Place$1")
                .replaceAll("^Platz([.,; ])", "Plein$1")
                .replaceAll("^Pl([.,; ])", "Place$1")
                .replaceAll("^Process([.,; ])", "Processing$1")
                .replaceAll("^Proc([.,; ])", "Processing$1")
                .replaceAll("^Products([.,; ])", "Production$1")
                .replaceAll("^Prod([.,; ])", "Production$1")
                .replaceAll("^Prof([.,; ])", "Production$1")
                .replaceAll("^Prop([.,; ])", "Production$1")
                .replaceAll("^Prot([.,; ])", "Protein$1")
                .replaceAll("^Province([.,; ])", "Provincial$1")
                .replaceAll("^Prov([.,; ])", "Province$1")
                .replaceAll("^Psychiatry([.,; ])", "Psychiatry$1")
                .replaceAll("^Psychiat([.,; ])", "Psychiatry$1")
                .replaceAll("^Pulm([.,; ])", "Pulmonary$1")
                .replaceAll("^Quim([.,; ])", "Quimica$1")
                .replaceAll("^Rd([.,; ])", "Road$1")
                .replaceAll("^Rech([.,; ])", "Recherche$1")
                .replaceAll("^Rehabil([.,; ])", "Rehabilitation$1")
                .replaceAll("^Rep of Georgia([.,; ])", "Republic of Georgia$1")
                .replaceAll("^Reproduction([.,; ])", "Reproductive$1")
                .replaceAll("^Reprod([.,; ])", "Reproduction$1")
                .replaceAll("^Resp([.,; ])", "Respiratory$1")
                .replaceAll("^Res([.,; ])", "Research$1")
                .replaceAll("^Ricerca([.,; ])", "Ricerche$1")
                .replaceAll("^Ric([.,; ])", "Ricerca$1")
                .replaceAll("^Sanat([.,; ])", "Sanatorium$1")
                .replaceAll("^Sanit([.,; ])", "Sanitary$1")
                .replaceAll("^Sao Tome E Prin([.,; ])", "Sao Tome E Principe$1")
                .replaceAll("^Sch([.,; ])", "School$1")
                .replaceAll("^Science([.,; ])", "Scientific$1")
                .replaceAll("^Sci([.,; ])", "Science$1")
                .replaceAll("^Semicond([.,; ])", "Semiconductor$1")
                .replaceAll("^Serv([.,; ])", "Service$1")
                .replaceAll("^Se([.,; ])", "Southeast$1")
                .replaceAll("^Soc([.,; ])", "Society$1")
                .replaceAll("^Southeast([.,; ])", "Southeast$1")
                .replaceAll("^Southwest([.,; ])", "Southeast$1")
                .replaceAll("^So([.,; ])", "Southern$1")
                .replaceAll("^Spect([.,; ])", "Spectroscopy$1")
                .replaceAll("^Sq([.,; ])", "Square$1")
                .replaceAll("^St Kitts & Nevi([.,; ])", "Saint Kitts & Nevis$1")
                .replaceAll("^Standard([.,; ])", "Standard$1")
                .replaceAll("^Stand([.,; ])", "Standard$1")
                .replaceAll("^Statistics([.,; ])", "Statistical$1")
                .replaceAll("^Stat([.,; ])", "Statistical$1")
                .replaceAll("^Stn([.,; ])", "Station$1")
                .replaceAll("^Structure([.,; ])", "Structure$1")
                .replaceAll("^Struct([.,; ])", "Structure$1")
                .replaceAll("^Str([.,; ])", "Straat$1")
                .replaceAll("^St([.,; ])", "Street$1")
                .replaceAll("^Substance([.,; ])", "Substances$1")
                .replaceAll("^Subst([.,; ])", "Substances$1")
                .replaceAll("^Super([.,; ])", "Super$1")
                .replaceAll("^Surgeon([.,; ])", "Surgeons$1")
                .replaceAll("^Surg([.,; ])", "Surgeons$1")
                .replaceAll("^Sw([.,; ])", "Southwest$1")
                .replaceAll("^Synth([.,; ])", "Synthesis$1")
                .replaceAll("^System([.,; ])", "System$1")
                .replaceAll("^Syst([.,; ])", "System$1")
                .replaceAll("^S([.,; ])", "South$1")
                .replaceAll("^Tb([.,; ])", "Tuberculosis$1")
                .replaceAll("^Technical([.,; ])", "Technical$1")
                .replaceAll("^Technische([.,; ])", "Technische$1")
                .replaceAll("^Tech([.,; ])", "Technical$1")
                .replaceAll("^Tel([.,; ])", "Telephone$1")
                .replaceAll("^Temp([.,; ])", "Temperature$1")
                .replaceAll("^Terr([.,; ])", "Terrestrial$1")
                .replaceAll("^Textile([.,; ])", "Textiles$1")
                .replaceAll("^Text([.,; ])", "Textiles$1")
                .replaceAll("^Trinid & Tobago([.,; ])", "Trinidad & Tobago$1")
                .replaceAll("^Tud([.,; ])", "Tudomanyos$1")
                .replaceAll("^U Arab Emirates([.,; ])", "United Arab Emirates$1")
                .replaceAll("^Univ([.,; ])", "University$1")
                .replaceAll("^USA([.,; ])", "United States of America$1")
                .replaceAll("^Vasc([.,; ])", "Vascular$1")
                .replaceAll("^Vet([.,; ])", "Veterns$1")
                .replaceAll("^Weap([.,; ])", "Weapons$1")
                .replaceAll("^Welf([.,; ])", "Welfare$1")
                .replaceAll("^Wissenschafter([.,; ])", "Wissenschafter$1")
                .replaceAll("^Wissenschaftes([.,; ])", "Wissenschaftes$1")
                .replaceAll("^Wissenschaft([.,; ])", "Wissenschaft$1")
                .replaceAll("^Wissensch([.,; ])", "Wissensch$1")
                .replaceAll("^W([.,; ])", "West$1")
                .replaceAll("^Zent([.,; ])", "Zentral$1");
        return str;
    }

    public static String reArgsBack(String str) {
        if (null == str || str.length() < 1) {
            return "";
        }
        str = str.replaceAll("([.,; ])Abt$", "$1Abteilung")
                .replaceAll("([.,; ])Academy$", "$1Academy")
                .replaceAll("([.,; ])Acad$", "$1Academy")
                .replaceAll("([.,; ])Accid$", "$1Accident")
                .replaceAll("([.,; ])Administration$", "$1Administration")
                .replaceAll("([.,; ])Adm$", "$1Administration")
                .replaceAll("([.,; ])Adv$", "$1Advance(d)")
                .replaceAll("([.,; ])Aerosp$", "$1Aerospace")
                .replaceAll("([.,; ])Agcy$", "$1Agency")
                .replaceAll("([.,; ])Agriculture$", "$1Agricultural")
                .replaceAll("([.,; ])Agr$", "$1Agricultural")
                .replaceAll("([.,; ])Akad$", "$1Accident")
                .replaceAll("([.,; ])Amer$", "$1America(n)")
                .replaceAll("([.,; ])Anal$", "$1Analysis")
                .replaceAll("([.,; ])Anatomie$", "$1Anatomia")
                .replaceAll("([.,; ])Anatomy$", "$1Anatomia")
                .replaceAll("([.,; ])Anat$", "$1Anatomia")
                .replaceAll("([.,; ])Angew$", "$1Angewandte")
                .replaceAll("([.,; ])Anim$", "$1Animal")
                .replaceAll("([.,; ])Antigua & Barbu$", "$1Antigua & Barbuda")
                .replaceAll("([.,; ])Apparat$", "$1Apparatus")
                .replaceAll("([.,; ])Appl$", "$1Applied")
                .replaceAll("([.,; ])Arthrit$", "$1Arthritis")
                .replaceAll("([.,; ])Assoc$", "$1Association")
                .replaceAll("([.,; ])Augenklin$", "$1Augenklinik")
                .replaceAll("([.,; ])Ave$", "$1Avenue")
                .replaceAll("([.,; ])Behavior$", "$1Behavior")
                .replaceAll("([.,; ])Behaviour$", "$1Behavior")
                .replaceAll("([.,; ])Behav$", "$1Behavior")
                .replaceAll("([.,; ])Biochem$", "$1Biochemistry")
                .replaceAll("([.,; ])Biologie$", "$1Biologie")
                .replaceAll("([.,; ])Biology$", "$1Biologie")
                .replaceAll("([.,; ])Biol$", "$1Biologie")
                .replaceAll("([.,; ])Bldg$", "$1Building")
                .replaceAll("([.,; ])Blvd$", "$1Boulevard")
                .replaceAll("([.,; ])Bosnia & Herceg$", "$1Bosnia & Hercegovina")
                .replaceAll("([.,; ])Botanic$", "$1Botanical")
                .replaceAll("([.,; ])Botany$", "$1Botanical")
                .replaceAll("([.,; ])Bot$", "$1Botanical")
                .replaceAll("([.,; ])Bros$", "$1Brothers")
                .replaceAll("([.,; ])Bur$", "$1Bureau")
                .replaceAll("([.,; ])Canc$", "$1Cancer")
                .replaceAll("([.,; ])Cent Afr Republ$", "$1Central African Republic")
                .replaceAll("([.,; ])Cent$", "$1Central")
                .replaceAll("([.,; ])Chemistry$", "$1Chemistry")
                .replaceAll("([.,; ])Chem$", "$1Chemistry")
                .replaceAll("([.,; ])Chim$", "$1Chemistry")
                .replaceAll("([.,; ])Chirurg$", "$1Chirurgie")
                .replaceAll("([.,; ])Cient$", "$1Cientificas")
                .replaceAll("([.,; ])Clinic$", "$1Clinical")
                .replaceAll("([.,; ])Clin$", "$1Clinical")
                .replaceAll("([.,; ])Coll$", "$1College")
                .replaceAll("([.,; ])Commun$", "$1Communication")
                .replaceAll("([.,; ])Comm$", "$1Committee")
                .replaceAll("([.,; ])Computer$", "$1Computer")
                .replaceAll("([.,; ])Comp$", "$1Computer")
                .replaceAll("([.,; ])Com$", "$1Comite")
                .replaceAll("([.,; ])Conf$", "$1Conference")
                .replaceAll("([.,; ])Corporation$", "$1Corporate")
                .replaceAll("([.,; ])Corp$", "$1Corporation")
                .replaceAll("([.,; ])Co$", "$1Company")
                .replaceAll("([.,; ])Cpds$", "$1Compounds")
                .replaceAll("([.,; ])Ctr$", "$1Center")
                .replaceAll("([.,; ])Cty$", "$1County")
                .replaceAll("([.,; ])Cytologie$", "$1Cytologie")
                .replaceAll("([.,; ])Cytology$", "$1Cytologie")
                .replaceAll("([.,; ])Cytol$", "$1Cytologie")
                .replaceAll("([.,; ])Def$", "$1Defence or Defense")
                .replaceAll("([.,; ])Dental$", "$1Dentistry")
                .replaceAll("([.,; ])Dent$", "$1Dentistry")
                .replaceAll("([.,; ])Dept$", "$1Department")
                .replaceAll("([.,; ])Deutschen$", "$1Deutschen")
                .replaceAll("([.,; ])Deutscher$", "$1Deutschen")
                .replaceAll("([.,; ])Deutsches$", "$1Deutsches")
                .replaceAll("([.,; ])Deutsche$", "$1Deutsches")
                .replaceAll("([.,; ])Deutsch$", "$1Deutsches")
                .replaceAll("([.,; ])Development$", "$1Development")
                .replaceAll("([.,; ])Dev$", "$1Development")
                .replaceAll("([.,; ])Diabet$", "$1Diabet")
                .replaceAll("([.,; ])Diag$", "$1Diagnosis")
                .replaceAll("([.,; ])Disease$", "$1Diseases")
                .replaceAll("([.,; ])Dist$", "$1District")
                .replaceAll("([.,; ])Dis$", "$1Diseases")
                .replaceAll("([.,; ])Div$", "$1Division")
                .replaceAll("([.,; ])Dominican Rep$", "$1Dominican Republic")
                .replaceAll("([.,; ])Dr$", "$1Drive")
                .replaceAll("([.,; ])Econ$", "$1Economy")
                .replaceAll("([.,; ])Education$", "$1Education")
                .replaceAll("([.,; ])Educ$", "$1Education")
                .replaceAll("([.,; ])EEG$", "$1Electroencephalographic")
                .replaceAll("([.,; ])Egyet$", "$1Egyetem")
                .replaceAll("([.,; ])Electrical$", "$1Electrical")
                .replaceAll("([.,; ])Electricity$", "$1Electrical")
                .replaceAll("([.,; ])Electric$", "$1Electrical")
                .replaceAll("([.,; ])Electroencephalographic$", "$1Electroencephalography")
                .replaceAll("([.,; ])Electronic$", "$1Electrical")
                .replaceAll("([.,; ])Elect$", "$1Electrical")
                .replaceAll("([.,; ])Elektrische$", "$1Electrical")
                .replaceAll("([.,; ])Elektrizitat$", "$1Electrical")
                .replaceAll("([.,; ])Elektronic$", "$1Electrical")
                .replaceAll("([.,; ])Elekt$", "$1Electrical")
                .replaceAll("([.,; ])Engineering$", "$1Electrical")
                .replaceAll("([.,; ])Engn$", "$1Electrical")
                .replaceAll("([.,; ])Environment$", "$1Environment")
                .replaceAll("([.,; ])Environm$", "$1Environment")
                .replaceAll("([.,; ])Equat Guinea$", "$1Equatorial Guinea")
                .replaceAll("([.,; ])Establishment$", "$1Etablissement")
                .replaceAll("([.,; ])Estab$", "$1Establishment")
                .replaceAll("([.,; ])Estab$", "$1Etablissement")
                .replaceAll("([.,; ])Etab$", "$1Etablissement")
                .replaceAll("([.,; ])Etud$", "$1Étude")
                .replaceAll("([.,; ])Experiment$", "$1Experiment")
                .replaceAll("([.,; ])Expt$", "$1Experiment")
                .replaceAll("([.,; ])E$", "$1East")
                .replaceAll("([.,; ])Fac$", "$1Faculty")
                .replaceAll("([.,; ])Fak$", "$1Fakultat")
                .replaceAll("([.,; ])Farm$", "$1Farmacia")
                .replaceAll("([.,; ])Fdn$", "$1Foundation")
                .replaceAll("([.,; ])Fed$", "$1Federal")
                .replaceAll("([.,; ])Fis$", "$1Fisica")
                .replaceAll("([.,; ])Forsch$", "$1Forschung")
                .replaceAll("([.,; ])Foundation$", "$1Fundacion")
                .replaceAll("([.,; ])Fr Austr Lands$", "$1French Austral Lands")
                .replaceAll("([.,; ])Fr Polynesia$", "$1French Polynesia")
                .replaceAll("([.,; ])Ft$", "$1Fort")
                .replaceAll("([.,; ])Fys$", "$1Fysica")
                .replaceAll("([.,; ])Gen$", "$1General")
                .replaceAll("([.,; ])Geol$", "$1Geology")
                .replaceAll("([.,; ])Gesell$", "$1Gesellschaft")
                .replaceAll("([.,; ])Govt$", "$1Government")
                .replaceAll("([.,; ])Grad$", "$1Graduate")
                .replaceAll("([.,; ])Group$", "$1Gruppe")
                .replaceAll("([.,; ])Grp$", "$1Group")
                .replaceAll("([.,; ])Hgsk$", "$1Hogeskole")
                .replaceAll("([.,; ])Historic$", "$1Historical")
                .replaceAll("([.,; ])History$", "$1Historical")
                .replaceAll("([.,; ])Hist$", "$1Historical")
                .replaceAll("([.,; ])Hlth$", "$1Health")
                .replaceAll("([.,; ])Hop$", "$1Hospital")
                .replaceAll("([.,; ])Horticulture$", "$1Horticultural")
                .replaceAll("([.,; ])Hort$", "$1Horticultural")
                .replaceAll("([.,; ])Hosp$", "$1Hospital")
                .replaceAll("([.,; ])Hsch$", "$1Hochschule")
                .replaceAll("([.,; ])Hts$", "$1Heights")
                .replaceAll("([.,; ])Husb$", "$1Husbandry")
                .replaceAll("([.,; ])Hyg$", "$1Hygiene")
                .replaceAll("([.,; ])Immunol$", "$1Immunology")
                .replaceAll("([.,; ])Inc$", "$1Incorporated")
                .replaceAll("([.,; ])Industry$", "$1Industrial")
                .replaceAll("([.,; ])Ind$", "$1Industrial")
                .replaceAll("([.,; ])Ind$", "$1Industry")
                .replaceAll("([.,; ])Infect$", "$1Infectious")
                .replaceAll("([.,; ])Infirm$", "$1Infirmary")
                .replaceAll("([.,; ])Ingegneria$", "$1Ingenieria")
                .replaceAll("([.,; ])Ingenieria$", "$1Ingenieria")
                .replaceAll("([.,; ])Ingn$", "$1Ingenieria")
                .replaceAll("([.,; ])Institute$", "$1Institutional")
                .replaceAll("([.,; ])Institute$", "$1Ist")
                .replaceAll("([.,; ])Inst$", "$1Institute")
                .replaceAll("([.,; ])Intro$", "$1Introduction")
                .replaceAll("([.,; ])Int$", "$1International")
                .replaceAll("([.,; ])Investigation$", "$1Investigational")
                .replaceAll("([.,; ])Invest$", "$1Investigational")
                .replaceAll("([.,; ])Isit$", "$1Institutional")
                .replaceAll("([.,; ])Isl$", "$1Island")
                .replaceAll("([.,; ])Istituto$", "$1Institutional")
                .replaceAll("([.,; ])Jr$", "$1Junior")
                .replaceAll("([.,; ])Kardiol$", "$1Kardiologie")
                .replaceAll("([.,; ])Kem$", "$1Kemiai")
                .replaceAll("([.,; ])Klin$", "$1Klinik")
                .replaceAll("([.,; ])Konf$", "$1Konference")
                .replaceAll("([.,; ])Laboratory$", "$1Laboratories")
                .replaceAll("([.,; ])Labs$", "$1Laboratories")
                .replaceAll("([.,; ])Lab$", "$1Laboratories")
                .replaceAll("([.,; ])Lect$", "$1Lecture")
                .replaceAll("([.,; ])Lib$", "$1Library")
                .replaceAll("([.,; ])Ltd$", "$1Limited")
                .replaceAll("([.,; ])Malad$", "$1Maladies")
                .replaceAll("([.,; ])Malagasy Republ$", "$1Malagasy Republic")
                .replaceAll("([.,; ])Matemat$", "$1Matematicky")
                .replaceAll("([.,; ])Mathematics$", "$1Mathematical")
                .replaceAll("([.,; ])Math$", "$1Mathematics")
                .replaceAll("([.,; ])Mat$", "$1Material")
                .replaceAll("([.,; ])Mechanical$", "$1Mechanical")
                .replaceAll("([.,; ])Mechanics$", "$1Mechanical")
                .replaceAll("([.,; ])Mech$", "$1Mechanical")
                .replaceAll("([.,; ])Medical$", "$1Medicinal")
                .replaceAll("([.,; ])Medicinal$", "$1Medicinal")
                .replaceAll("([.,; ])Medicine$", "$1Medicinal")
                .replaceAll("([.,; ])Meditskkaya$", "$1Medizin")
                .replaceAll("([.,; ])Med$", "$1Medical")
                .replaceAll("([.,; ])Mem$", "$1Memorial")
                .replaceAll("([.,; ])Metabolic$", "$1Metabolism")
                .replaceAll("([.,; ])Metab$", "$1Metabolic")
                .replaceAll("([.,; ])Metallurgy$", "$1Metabolic")
                .replaceAll("([.,; ])Metal$", "$1Metabolic")
                .replaceAll("([.,; ])Met$", "$1Metallurgical")
                .replaceAll("([.,; ])Mfg$", "$1Manufacturing")
                .replaceAll("([.,; ])Mil$", "$1Military")
                .replaceAll("([.,; ])Minist$", "$1Ministry")
                .replaceAll("([.,; ])Min$", "$1Mining")
                .replaceAll("([.,; ])Mkt$", "$1Mining")
                .replaceAll("([.,; ])Molecule$", "$1Molekular")
                .replaceAll("([.,; ])Mol$", "$1Molecular")
                .replaceAll("([.,; ])Mongol Peo Rep$", "$1Mongolian People's Republic")
                .replaceAll("([.,; ])Mount$", "$1Mountain")
                .replaceAll("([.,; ])Mt$", "$1Mountain")
                .replaceAll("([.,; ])Nacional$", "$1Nacional")
                .replaceAll("([.,; ])National$", "$1Nacional")
                .replaceAll("([.,; ])Natl$", "$1Nacional")
                .replaceAll("([.,; ])Nature$", "$1Nacional")
                .replaceAll("([.,; ])Nat$", "$1Nature")
                .replaceAll("([.,; ])Navigation$", "$1Navigational")
                .replaceAll("([.,; ])Nav$", "$1Navigational")
                .replaceAll("([.,; ])Nazionale$", "$1Nazionale")
                .replaceAll("([.,; ])Neth Antilles$", "$1Netherlands Antilles")
                .replaceAll("([.,; ])NE$", "$1Northeast")
                .replaceAll("([.,; ])North Ireland$", "$1Northern Ireland")
                .replaceAll("([.,; ])Northeast$", "$1Northeastern")
                .replaceAll("([.,; ])Northwest$", "$1Northwestern")
                .replaceAll("([.,; ])No$", "$1Northern")
                .replaceAll("([.,; ])Nucl$", "$1Nuclear")
                .replaceAll("([.,; ])Nukl$", "$1Nuklear")
                .replaceAll("([.,; ])Nutr$", "$1Nutrition")
                .replaceAll("([.,; ])NW$", "$1Northwest")
                .replaceAll("([.,; ])N$", "$1North")
                .replaceAll("([.,; ])Observ$", "$1Observatory")
                .replaceAll("([.,; ])Obstet$", "$1Obstetrics")
                .replaceAll("([.,; ])Off$", "$1Office")
                .replaceAll("([.,; ])Organization$", "$1Organizational")
                .replaceAll("([.,; ])Org$", "$1Organization")
                .replaceAll("([.,; ])Osped$", "$1Ospedale")
                .replaceAll("([.,; ])Paediatric$", "$1Paediatric")
                .replaceAll("([.,; ])Paediat$", "$1Paediat")
                .replaceAll("([.,; ])Papua N Guinea$", "$1Papua New Guinea")
                .replaceAll("([.,; ])Pediatric$", "$1Pediatrics")
                .replaceAll("([.,; ])Peoples R China$", "$1People's Republic of China")
                .replaceAll("([.,; ])Petr$", "$1Petroleum")
                .replaceAll("([.,; ])Pharm$", "$1Pharmacy")
                .replaceAll("([.,; ])Phys$", "$1Physical")
                .replaceAll("([.,; ])Pkwy$", "$1Parkway")
                .replaceAll("([.,; ])Pk$", "$1Park")
                .replaceAll("([.,; ])Place$", "$1Place")
                .replaceAll("([.,; ])Platz$", "$1Plein")
                .replaceAll("([.,; ])Pl$", "$1Place")
                .replaceAll("([.,; ])Process$", "$1Processing")
                .replaceAll("([.,; ])Proc$", "$1Processing")
                .replaceAll("([.,; ])Products$", "$1Production")
                .replaceAll("([.,; ])Prod$", "$1Production")
                .replaceAll("([.,; ])Prof$", "$1Production")
                .replaceAll("([.,; ])Prop$", "$1Production")
                .replaceAll("([.,; ])Prot$", "$1Protein")
                .replaceAll("([.,; ])Province$", "$1Provincial")
                .replaceAll("([.,; ])Prov$", "$1Province")
                .replaceAll("([.,; ])Psychiatry$", "$1Psychiatry")
                .replaceAll("([.,; ])Psychiat$", "$1Psychiatry")
                .replaceAll("([.,; ])Pulm$", "$1Pulmonary")
                .replaceAll("([.,; ])Quim$", "$1Quimica")
                .replaceAll("([.,; ])Rd$", "$1Road")
                .replaceAll("([.,; ])Rech$", "$1Recherche")
                .replaceAll("([.,; ])Rehabil$", "$1Rehabilitation")
                .replaceAll("([.,; ])Rep of Georgia$", "$1Republic of Georgia")
                .replaceAll("([.,; ])Reproduction$", "$1Reproductive")
                .replaceAll("([.,; ])Reprod$", "$1Reproduction")
                .replaceAll("([.,; ])Resp$", "$1Respiratory")
                .replaceAll("([.,; ])Res$", "$1Research")
                .replaceAll("([.,; ])Ricerca$", "$1Ricerche")
                .replaceAll("([.,; ])Ric$", "$1Ricerca")
                .replaceAll("([.,; ])Sanat$", "$1Sanatorium")
                .replaceAll("([.,; ])Sanit$", "$1Sanitary")
                .replaceAll("([.,; ])Sao Tome E Prin$", "$1Sao Tome E Principe")
                .replaceAll("([.,; ])Sch$", "$1School")
                .replaceAll("([.,; ])Science$", "$1Scientific")
                .replaceAll("([.,; ])Sci$", "$1Science")
                .replaceAll("([.,; ])Semicond$", "$1Semiconductor")
                .replaceAll("([.,; ])Serv$", "$1Service")
                .replaceAll("([.,; ])Se$", "$1Southeast")
                .replaceAll("([.,; ])Soc$", "$1Society")
                .replaceAll("([.,; ])Southeast$", "$1Southeast")
                .replaceAll("([.,; ])Southwest$", "$1Southeast")
                .replaceAll("([.,; ])So$", "$1Southern")
                .replaceAll("([.,; ])Spect$", "$1Spectroscopy")
                .replaceAll("([.,; ])Sq$", "$1Square")
                .replaceAll("([.,; ])St Kitts & Nevi$", "$1Saint Kitts & Nevis")
                .replaceAll("([.,; ])Standard$", "$1Standard")
                .replaceAll("([.,; ])Stand$", "$1Standard")
                .replaceAll("([.,; ])Statistics$", "$1Statistical")
                .replaceAll("([.,; ])Stat$", "$1Statistical")
                .replaceAll("([.,; ])Stn$", "$1Station")
                .replaceAll("([.,; ])Structure$", "$1Structure")
                .replaceAll("([.,; ])Struct$", "$1Structure")
                .replaceAll("([.,; ])Str$", "$1Straat")
                .replaceAll("([.,; ])St$", "$1Street")
                .replaceAll("([.,; ])Substance$", "$1Substances")
                .replaceAll("([.,; ])Subst$", "$1Substances")
                .replaceAll("([.,; ])Super$", "$1Super")
                .replaceAll("([.,; ])Surgeon$", "$1Surgeons")
                .replaceAll("([.,; ])Surg$", "$1Surgeons")
                .replaceAll("([.,; ])Sw$", "$1Southwest")
                .replaceAll("([.,; ])Synth$", "$1Synthesis")
                .replaceAll("([.,; ])System$", "$1System")
                .replaceAll("([.,; ])Syst$", "$1System")
                .replaceAll("([.,; ])S$", "$1South")
                .replaceAll("([.,; ])Tb$", "$1Tuberculosis")
                .replaceAll("([.,; ])Technical$", "$1Technical")
                .replaceAll("([.,; ])Technische$", "$1Technische")
                .replaceAll("([.,; ])Tech$", "$1Technical")
                .replaceAll("([.,; ])Tel$", "$1Telephone")
                .replaceAll("([.,; ])Temp$", "$1Temperature")
                .replaceAll("([.,; ])Terr$", "$1Terrestrial")
                .replaceAll("([.,; ])Textile$", "$1Textiles")
                .replaceAll("([.,; ])Text$", "$1Textiles")
                .replaceAll("([.,; ])Trinid & Tobago$", "$1Trinidad & Tobago")
                .replaceAll("([.,; ])Tud$", "$1Tudomanyos")
                .replaceAll("([.,; ])U Arab Emirates$", "$1United Arab Emirates")
                .replaceAll("([.,; ])Univ$", "$1University")
                .replaceAll("([.,; ])USA$", "$1United States of America")
                .replaceAll("([.,; ])Vasc$", "$1Vascular")
                .replaceAll("([.,; ])Vet$", "$1Veterns")
                .replaceAll("([.,; ])Weap$", "$1Weapons")
                .replaceAll("([.,; ])Welf$", "$1Welfare")
                .replaceAll("([.,; ])Wissenschafter$", "$1Wissenschafter")
                .replaceAll("([.,; ])Wissenschaftes$", "$1Wissenschaftes")
                .replaceAll("([.,; ])Wissenschaft$", "$1Wissenschaft")
                .replaceAll("([.,; ])Wissensch$", "$1Wissensch")
                .replaceAll("([.,; ])W$", "$1West")
                .replaceAll("([.,; ])Zent$", "$1Zentral");
        return str;
    }


    // 规范WOS表中的作者单位信息部分。
    public static String reArgs(String str) {
        if (null == str || str.length() < 1) {
            return "";
        }
        str = str.replaceAll("([.,; ])Abt([.,; ])", "$1Abteilung$2")
                .replaceAll("([.,; ])Academy([.,; ])", "$1Academy$2")
                .replaceAll("([.,; ])Acad([.,; ])", "$1Academy$2")
                .replaceAll("([.,; ])Accid([.,; ])", "$1Accident$2")
                .replaceAll("([.,; ])Administration([.,; ])", "$1Administration$2")
                .replaceAll("([.,; ])Adm([.,; ])", "$1Administration$2")
                .replaceAll("([.,; ])Adv([.,; ])", "$1Advance(d)$2")
                .replaceAll("([.,; ])Aerosp([.,; ])", "$1Aerospace$2")
                .replaceAll("([.,; ])Agcy([.,; ])", "$1Agency$2")
                .replaceAll("([.,; ])Agriculture([.,; ])", "$1Agricultural$2")
                .replaceAll("([.,; ])Agr([.,; ])", "$1Agricultural$2")
                .replaceAll("([.,; ])Akad([.,; ])", "$1Accident$2")
                .replaceAll("([.,; ])Amer([.,; ])", "$1America(n)$2")
                .replaceAll("([.,; ])Anal([.,; ])", "$1Analysis$2")
                .replaceAll("([.,; ])Anatomie([.,; ])", "$1Anatomia$2")
                .replaceAll("([.,; ])Anatomy([.,; ])", "$1Anatomia$2")
                .replaceAll("([.,; ])Anat([.,; ])", "$1Anatomia$2")
                .replaceAll("([.,; ])Angew([.,; ])", "$1Angewandte$2")
                .replaceAll("([.,; ])Anim([.,; ])", "$1Animal$2")
                .replaceAll("([.,; ])Antigua & Barbu([.,; ])", "$1Antigua & Barbuda$2")
                .replaceAll("([.,; ])Apparat([.,; ])", "$1Apparatus$2")
                .replaceAll("([.,; ])Appl([.,; ])", "$1Applied$2")
                .replaceAll("([.,; ])Arthrit([.,; ])", "$1Arthritis$2")
                .replaceAll("([.,; ])Assoc([.,; ])", "$1Association$2")
                .replaceAll("([.,; ])Augenklin([.,; ])", "$1Augenklinik$2")
                .replaceAll("([.,; ])Ave([.,; ])", "$1Avenue$2")
                .replaceAll("([.,; ])Behavior([.,; ])", "$1Behavior$2")
                .replaceAll("([.,; ])Behaviour([.,; ])", "$1Behavior$2")
                .replaceAll("([.,; ])Behav([.,; ])", "$1Behavior$2")
                .replaceAll("([.,; ])Biochem([.,; ])", "$1Biochemistry$2")
                .replaceAll("([.,; ])Biologie([.,; ])", "$1Biologie$2")
                .replaceAll("([.,; ])Biology([.,; ])", "$1Biologie$2")
                .replaceAll("([.,; ])Biol([.,; ])", "$1Biologie$2")
                .replaceAll("([.,; ])Bldg([.,; ])", "$1Building$2")
                .replaceAll("([.,; ])Blvd([.,; ])", "$1Boulevard$2")
                .replaceAll("([.,; ])Bosnia & Herceg([.,; ])", "$1Bosnia & Hercegovina$2")
                .replaceAll("([.,; ])Botanic([.,; ])", "$1Botanical$2")
                .replaceAll("([.,; ])Botany([.,; ])", "$1Botanical$2")
                .replaceAll("([.,; ])Bot([.,; ])", "$1Botanical$2")
                .replaceAll("([.,; ])Bros([.,; ])", "$1Brothers$2")
                .replaceAll("([.,; ])Bur([.,; ])", "$1Bureau$2")
                .replaceAll("([.,; ])Canc([.,; ])", "$1Cancer$2")
                .replaceAll("([.,; ])Cent Afr Republ([.,; ])", "$1Central African Republic$2")
                .replaceAll("([.,; ])Cent([.,; ])", "$1Central$2")
                .replaceAll("([.,; ])Chemistry([.,; ])", "$1Chemistry$2")
                .replaceAll("([.,; ])Chem([.,; ])", "$1Chemistry$2")
                .replaceAll("([.,; ])Chim([.,; ])", "$1Chemistry$2")
                .replaceAll("([.,; ])Chirurg([.,; ])", "$1Chirurgie$2")
                .replaceAll("([.,; ])Cient([.,; ])", "$1Cientificas$2")
                .replaceAll("([.,; ])Clinic([.,; ])", "$1Clinical$2")
                .replaceAll("([.,; ])Clin([.,; ])", "$1Clinical$2")
                .replaceAll("([.,; ])Coll([.,; ])", "$1College$2")
                .replaceAll("([.,; ])Commun([.,; ])", "$1Communication$2")
                .replaceAll("([.,; ])Comm([.,; ])", "$1Committee$2")
                .replaceAll("([.,; ])Computer([.,; ])", "$1Computer$2")
                .replaceAll("([.,; ])Comp([.,; ])", "$1Computer$2")
                .replaceAll("([.,; ])Com([.,; ])", "$1Comite$2")
                .replaceAll("([.,; ])Conf([.,; ])", "$1Conference$2")
                .replaceAll("([.,; ])Corporation([.,; ])", "$1Corporate$2")
                .replaceAll("([.,; ])Corp([.,; ])", "$1Corporation$2")
                .replaceAll("([.,; ])Co([.,; ])", "$1Company$2")
                .replaceAll("([.,; ])Cpds([.,; ])", "$1Compounds$2")
                .replaceAll("([.,; ])Ctr([.,; ])", "$1Center$2")
                .replaceAll("([.,; ])Cty([.,; ])", "$1County$2")
                .replaceAll("([.,; ])Cytologie([.,; ])", "$1Cytologie$2")
                .replaceAll("([.,; ])Cytology([.,; ])", "$1Cytologie$2")
                .replaceAll("([.,; ])Cytol([.,; ])", "$1Cytologie$2")
                .replaceAll("([.,; ])Def([.,; ])", "$1Defence or Defense$2")
                .replaceAll("([.,; ])Dental([.,; ])", "$1Dentistry$2")
                .replaceAll("([.,; ])Dent([.,; ])", "$1Dentistry$2")
                .replaceAll("([.,; ])Dept([.,; ])", "$1Department$2")
                .replaceAll("([.,; ])Deutschen([.,; ])", "$1Deutschen$2")
                .replaceAll("([.,; ])Deutscher([.,; ])", "$1Deutschen$2")
                .replaceAll("([.,; ])Deutsches([.,; ])", "$1Deutsches$2")
                .replaceAll("([.,; ])Deutsche([.,; ])", "$1Deutsches$2")
                .replaceAll("([.,; ])Deutsch([.,; ])", "$1Deutsches$2")
                .replaceAll("([.,; ])Development([.,; ])", "$1Development$2")
                .replaceAll("([.,; ])Dev([.,; ])", "$1Development$2")
                .replaceAll("([.,; ])Diabet([.,; ])", "$1Diabet$2")
                .replaceAll("([.,; ])Diag([.,; ])", "$1Diagnosis$2")
                .replaceAll("([.,; ])Disease([.,; ])", "$1Diseases$2")
                .replaceAll("([.,; ])Dist([.,; ])", "$1District$2")
                .replaceAll("([.,; ])Dis([.,; ])", "$1Diseases$2")
                .replaceAll("([.,; ])Div([.,; ])", "$1Division$2")
                .replaceAll("([.,; ])Dominican Rep([.,; ])", "$1Dominican Republic$2")
                .replaceAll("([.,; ])Dr([.,; ])", "$1Drive$2")
                .replaceAll("([.,; ])Econ([.,; ])", "$1Economy$2")
                .replaceAll("([.,; ])Education([.,; ])", "$1Education$2")
                .replaceAll("([.,; ])Educ([.,; ])", "$1Education$2")
                .replaceAll("([.,; ])EEG([.,; ])", "$1Electroencephalographic$2")
                .replaceAll("([.,; ])Egyet([.,; ])", "$1Egyetem$2")
                .replaceAll("([.,; ])Electrical([.,; ])", "$1Electrical$2")
                .replaceAll("([.,; ])Electricity([.,; ])", "$1Electrical$2")
                .replaceAll("([.,; ])Electric([.,; ])", "$1Electrical$2")
                .replaceAll("([.,; ])Electroencephalographic([.,; ])", "$1Electroencephalography$2")
                .replaceAll("([.,; ])Electronic([.,; ])", "$1Electrical$2")
                .replaceAll("([.,; ])Elect([.,; ])", "$1Electrical$2")
                .replaceAll("([.,; ])Elektrische([.,; ])", "$1Electrical$2")
                .replaceAll("([.,; ])Elektrizitat([.,; ])", "$1Electrical$2")
                .replaceAll("([.,; ])Elektronic([.,; ])", "$1Electrical$2")
                .replaceAll("([.,; ])Elekt([.,; ])", "$1Electrical$2")
                .replaceAll("([.,; ])Engineering([.,; ])", "$1Electrical$2")
                .replaceAll("([.,; ])Engn([.,; ])", "$1Electrical$2")
                .replaceAll("([.,; ])Environment([.,; ])", "$1Environment$2")
                .replaceAll("([.,; ])Environm([.,; ])", "$1Environment$2")
                .replaceAll("([.,; ])Equat Guinea([.,; ])", "$1Equatorial Guinea$2")
                .replaceAll("([.,; ])Establishment([.,; ])", "$1Etablissement$2")
                .replaceAll("([.,; ])Estab([.,; ])", "$1Establishment$2")
                .replaceAll("([.,; ])Estab([.,; ])", "$1Etablissement$2")
                .replaceAll("([.,; ])Etab([.,; ])", "$1Etablissement$2")
                .replaceAll("([.,; ])Etud([.,; ])", "$1Étude$2")
                .replaceAll("([.,; ])Experiment([.,; ])", "$1Experiment$2")
                .replaceAll("([.,; ])Expt([.,; ])", "$1Experiment$2")
                .replaceAll("([.,; ])E([.,; ])", "$1East$2")
                .replaceAll("([.,; ])Fac([.,; ])", "$1Faculty$2")
                .replaceAll("([.,; ])Fak([.,; ])", "$1Fakultat$2")
                .replaceAll("([.,; ])Farm([.,; ])", "$1Farmacia$2")
                .replaceAll("([.,; ])Fdn([.,; ])", "$1Foundation$2")
                .replaceAll("([.,; ])Fed([.,; ])", "$1Federal$2")
                .replaceAll("([.,; ])Fis([.,; ])", "$1Fisica$2")
                .replaceAll("([.,; ])Forsch([.,; ])", "$1Forschung$2")
                .replaceAll("([.,; ])Foundation([.,; ])", "$1Fundacion$2")
                .replaceAll("([.,; ])Fr Austr Lands([.,; ])", "$1French Austral Lands$2")
                .replaceAll("([.,; ])Fr Polynesia([.,; ])", "$1French Polynesia$2")
                .replaceAll("([.,; ])Ft([.,; ])", "$1Fort$2")
                .replaceAll("([.,; ])Fys([.,; ])", "$1Fysica$2")
                .replaceAll("([.,; ])Gen([.,; ])", "$1General$2")
                .replaceAll("([.,; ])Geol([.,; ])", "$1Geology$2")
                .replaceAll("([.,; ])Gesell([.,; ])", "$1Gesellschaft$2")
                .replaceAll("([.,; ])Govt([.,; ])", "$1Government$2")
                .replaceAll("([.,; ])Grad([.,; ])", "$1Graduate$2")
                .replaceAll("([.,; ])Group([.,; ])", "$1Gruppe$2")
                .replaceAll("([.,; ])Grp([.,; ])", "$1Group$2")
                .replaceAll("([.,; ])Hgsk([.,; ])", "$1Hogeskole$2")
                .replaceAll("([.,; ])Historic([.,; ])", "$1Historical$2")
                .replaceAll("([.,; ])History([.,; ])", "$1Historical$2")
                .replaceAll("([.,; ])Hist([.,; ])", "$1Historical$2")
                .replaceAll("([.,; ])Hlth([.,; ])", "$1Health$2")
                .replaceAll("([.,; ])Hop([.,; ])", "$1Hospital$2")
                .replaceAll("([.,; ])Horticulture([.,; ])", "$1Horticultural$2")
                .replaceAll("([.,; ])Hort([.,; ])", "$1Horticultural$2")
                .replaceAll("([.,; ])Hosp([.,; ])", "$1Hospital$2")
                .replaceAll("([.,; ])Hsch([.,; ])", "$1Hochschule$2")
                .replaceAll("([.,; ])Hts([.,; ])", "$1Heights$2")
                .replaceAll("([.,; ])Husb([.,; ])", "$1Husbandry$2")
                .replaceAll("([.,; ])Hyg([.,; ])", "$1Hygiene$2")
                .replaceAll("([.,; ])Immunol([.,; ])", "$1Immunology$2")
                .replaceAll("([.,; ])Inc([.,; ])", "$1Incorporated$2")
                .replaceAll("([.,; ])Industry([.,; ])", "$1Industrial$2")
                .replaceAll("([.,; ])Ind([.,; ])", "$1Industrial$2")
                .replaceAll("([.,; ])Ind([.,; ])", "$1Industry$2")
                .replaceAll("([.,; ])Infect([.,; ])", "$1Infectious$2")
                .replaceAll("([.,; ])Infirm([.,; ])", "$1Infirmary$2")
                .replaceAll("([.,; ])Ingegneria([.,; ])", "$1Ingenieria$2")
                .replaceAll("([.,; ])Ingenieria([.,; ])", "$1Ingenieria$2")
                .replaceAll("([.,; ])Ingn([.,; ])", "$1Ingenieria$2")
                .replaceAll("([.,; ])Institute([.,; ])", "$1Institutional$2")
                .replaceAll("([.,; ])Institute([.,; ])", "$1Ist$2")
                .replaceAll("([.,; ])Inst([.,; ])", "$1Institute$2")
                .replaceAll("([.,; ])Intro([.,; ])", "$1Introduction$2")
                .replaceAll("([.,; ])Int([.,; ])", "$1International$2")
                .replaceAll("([.,; ])Investigation([.,; ])", "$1Investigational$2")
                .replaceAll("([.,; ])Invest([.,; ])", "$1Investigational$2")
                .replaceAll("([.,; ])Isit([.,; ])", "$1Institutional$2")
                .replaceAll("([.,; ])Isl([.,; ])", "$1Island$2")
                .replaceAll("([.,; ])Istituto([.,; ])", "$1Institutional$2")
                .replaceAll("([.,; ])Jr([.,; ])", "$1Junior$2")
                .replaceAll("([.,; ])Kardiol([.,; ])", "$1Kardiologie$2")
                .replaceAll("([.,; ])Kem([.,; ])", "$1Kemiai$2")
                .replaceAll("([.,; ])Klin([.,; ])", "$1Klinik$2")
                .replaceAll("([.,; ])Konf([.,; ])", "$1Konference$2")
                .replaceAll("([.,; ])Laboratory([.,; ])", "$1Laboratories$2")
                .replaceAll("([.,; ])Labs([.,; ])", "$1Laboratories$2")
                .replaceAll("([.,; ])Lab([.,; ])", "$1Laboratories$2")
                .replaceAll("([.,; ])Lect([.,; ])", "$1Lecture$2")
                .replaceAll("([.,; ])Lib([.,; ])", "$1Library$2")
                .replaceAll("([.,; ])Ltd([.,; ])", "$1Limited$2")
                .replaceAll("([.,; ])Malad([.,; ])", "$1Maladies$2")
                .replaceAll("([.,; ])Malagasy Republ([.,; ])", "$1Malagasy Republic$2")
                .replaceAll("([.,; ])Matemat([.,; ])", "$1Matematicky$2")
                .replaceAll("([.,; ])Mathematics([.,; ])", "$1Mathematical$2")
                .replaceAll("([.,; ])Math([.,; ])", "$1Mathematics$2")
                .replaceAll("([.,; ])Mat([.,; ])", "$1Material$2")
                .replaceAll("([.,; ])Mechanical([.,; ])", "$1Mechanical$2")
                .replaceAll("([.,; ])Mechanics([.,; ])", "$1Mechanical$2")
                .replaceAll("([.,; ])Mech([.,; ])", "$1Mechanical$2")
                .replaceAll("([.,; ])Medical([.,; ])", "$1Medicinal$2")
                .replaceAll("([.,; ])Medicinal([.,; ])", "$1Medicinal$2")
                .replaceAll("([.,; ])Medicine([.,; ])", "$1Medicinal$2")
                .replaceAll("([.,; ])Meditskkaya([.,; ])", "$1Medizin$2")
                .replaceAll("([.,; ])Med([.,; ])", "$1Medical$2")
                .replaceAll("([.,; ])Mem([.,; ])", "$1Memorial$2")
                .replaceAll("([.,; ])Metabolic([.,; ])", "$1Metabolism$2")
                .replaceAll("([.,; ])Metab([.,; ])", "$1Metabolic$2")
                .replaceAll("([.,; ])Metallurgy([.,; ])", "$1Metabolic$2")
                .replaceAll("([.,; ])Metal([.,; ])", "$1Metabolic$2")
                .replaceAll("([.,; ])Met([.,; ])", "$1Metallurgical$2")
                .replaceAll("([.,; ])Mfg([.,; ])", "$1Manufacturing$2")
                .replaceAll("([.,; ])Mil([.,; ])", "$1Military$2")
                .replaceAll("([.,; ])Minist([.,; ])", "$1Ministry$2")
                .replaceAll("([.,; ])Min([.,; ])", "$1Mining$2")
                .replaceAll("([.,; ])Mkt([.,; ])", "$1Mining$2")
                .replaceAll("([.,; ])Molecule([.,; ])", "$1Molekular$2")
                .replaceAll("([.,; ])Mol([.,; ])", "$1Molecular$2")
                .replaceAll("([.,; ])Mongol Peo Rep([.,; ])", "$1Mongolian People's Republic$2")
                .replaceAll("([.,; ])Mount([.,; ])", "$1Mountain$2")
                .replaceAll("([.,; ])Mt([.,; ])", "$1Mountain$2")
                .replaceAll("([.,; ])Nacional([.,; ])", "$1Nacional$2")
                .replaceAll("([.,; ])National([.,; ])", "$1Nacional$2")
                .replaceAll("([.,; ])Natl([.,; ])", "$1Nacional$2")
                .replaceAll("([.,; ])Nature([.,; ])", "$1Nacional$2")
                .replaceAll("([.,; ])Nat([.,; ])", "$1Nature$2")
                .replaceAll("([.,; ])Navigation([.,; ])", "$1Navigational$2")
                .replaceAll("([.,; ])Nav([.,; ])", "$1Navigational$2")
                .replaceAll("([.,; ])Nazionale([.,; ])", "$1Nazionale$2")
                .replaceAll("([.,; ])Neth Antilles([.,; ])", "$1Netherlands Antilles$2")
                .replaceAll("([.,; ])NE([.,; ])", "$1Northeast$2")
                .replaceAll("([.,; ])North Ireland([.,; ])", "$1Northern Ireland$2")
                .replaceAll("([.,; ])Northeast([.,; ])", "$1Northeastern$2")
                .replaceAll("([.,; ])Northwest([.,; ])", "$1Northwestern$2")
                .replaceAll("([.,; ])No([.,; ])", "$1Northern$2")
                .replaceAll("([.,; ])Nucl([.,; ])", "$1Nuclear$2")
                .replaceAll("([.,; ])Nukl([.,; ])", "$1Nuklear$2")
                .replaceAll("([.,; ])Nutr([.,; ])", "$1Nutrition$2")
                .replaceAll("([.,; ])NW([.,; ])", "$1Northwest$2")
                .replaceAll("([.,; ])N([.,; ])", "$1North$2")
                .replaceAll("([.,; ])Observ([.,; ])", "$1Observatory$2")
                .replaceAll("([.,; ])Obstet([.,; ])", "$1Obstetrics$2")
                .replaceAll("([.,; ])Off([.,; ])", "$1Office$2")
                .replaceAll("([.,; ])Organization([.,; ])", "$1Organizational$2")
                .replaceAll("([.,; ])Org([.,; ])", "$1Organization$2")
                .replaceAll("([.,; ])Osped([.,; ])", "$1Ospedale$2")
                .replaceAll("([.,; ])Paediatric([.,; ])", "$1Paediatric$2")
                .replaceAll("([.,; ])Paediat([.,; ])", "$1Paediat$2")
                .replaceAll("([.,; ])Papua N Guinea([.,; ])", "$1Papua New Guinea$2")
                .replaceAll("([.,; ])Pediatric([.,; ])", "$1Pediatrics$2")
                .replaceAll("([.,; ])Peoples R China([.,; ])", "$1People's Republic of China$2")
                .replaceAll("([.,; ])Petr([.,; ])", "$1Petroleum$2")
                .replaceAll("([.,; ])Pharm([.,; ])", "$1Pharmacy$2")
                .replaceAll("([.,; ])Phys([.,; ])", "$1Physical$2")
                .replaceAll("([.,; ])Pkwy([.,; ])", "$1Parkway$2")
                .replaceAll("([.,; ])Pk([.,; ])", "$1Park$2")
                .replaceAll("([.,; ])Place([.,; ])", "$1Place$2")
                .replaceAll("([.,; ])Platz([.,; ])", "$1Plein$2")
                .replaceAll("([.,; ])Pl([.,; ])", "$1Place$2")
                .replaceAll("([.,; ])Process([.,; ])", "$1Processing$2")
                .replaceAll("([.,; ])Proc([.,; ])", "$1Processing$2")
                .replaceAll("([.,; ])Products([.,; ])", "$1Production$2")
                .replaceAll("([.,; ])Prod([.,; ])", "$1Production$2")
                .replaceAll("([.,; ])Prof([.,; ])", "$1Production$2")
                .replaceAll("([.,; ])Prop([.,; ])", "$1Production$2")
                .replaceAll("([.,; ])Prot([.,; ])", "$1Protein$2")
                .replaceAll("([.,; ])Province([.,; ])", "$1Provincial$2")
                .replaceAll("([.,; ])Prov([.,; ])", "$1Province$2")
                .replaceAll("([.,; ])Psychiatry([.,; ])", "$1Psychiatry$2")
                .replaceAll("([.,; ])Psychiat([.,; ])", "$1Psychiatry$2")
                .replaceAll("([.,; ])Pulm([.,; ])", "$1Pulmonary$2")
                .replaceAll("([.,; ])Quim([.,; ])", "$1Quimica$2")
                .replaceAll("([.,; ])Rd([.,; ])", "$1Road$2")
                .replaceAll("([.,; ])Rech([.,; ])", "$1Recherche$2")
                .replaceAll("([.,; ])Rehabil([.,; ])", "$1Rehabilitation$2")
                .replaceAll("([.,; ])Rep of Georgia([.,; ])", "$1Republic of Georgia$2")
                .replaceAll("([.,; ])Reproduction([.,; ])", "$1Reproductive$2")
                .replaceAll("([.,; ])Reprod([.,; ])", "$1Reproduction$2")
                .replaceAll("([.,; ])Resp([.,; ])", "$1Respiratory$2")
                .replaceAll("([.,; ])Res([.,; ])", "$1Research$2")
                .replaceAll("([.,; ])Ricerca([.,; ])", "$1Ricerche$2")
                .replaceAll("([.,; ])Ric([.,; ])", "$1Ricerca$2")
                .replaceAll("([.,; ])Sanat([.,; ])", "$1Sanatorium$2")
                .replaceAll("([.,; ])Sanit([.,; ])", "$1Sanitary$2")
                .replaceAll("([.,; ])Sao Tome E Prin([.,; ])", "$1Sao Tome E Principe$2")
                .replaceAll("([.,; ])Sch([.,; ])", "$1School$2")
                .replaceAll("([.,; ])Science([.,; ])", "$1Scientific$2")
                .replaceAll("([.,; ])Sci([.,; ])", "$1Science$2")
                .replaceAll("([.,; ])Semicond([.,; ])", "$1Semiconductor$2")
                .replaceAll("([.,; ])Serv([.,; ])", "$1Service$2")
                .replaceAll("([.,; ])Se([.,; ])", "$1Southeast$2")
                .replaceAll("([.,; ])Soc([.,; ])", "$1Society$2")
                .replaceAll("([.,; ])Southeast([.,; ])", "$1Southeast$2")
                .replaceAll("([.,; ])Southwest([.,; ])", "$1Southeast$2")
                .replaceAll("([.,; ])So([.,; ])", "$1Southern$2")
                .replaceAll("([.,; ])Spect([.,; ])", "$1Spectroscopy$2")
                .replaceAll("([.,; ])Sq([.,; ])", "$1Square$2")
                .replaceAll("([.,; ])St Kitts & Nevi([.,; ])", "$1Saint Kitts & Nevis$2")
                .replaceAll("([.,; ])Standard([.,; ])", "$1Standard$2")
                .replaceAll("([.,; ])Stand([.,; ])", "$1Standard$2")
                .replaceAll("([.,; ])Statistics([.,; ])", "$1Statistical$2")
                .replaceAll("([.,; ])Stat([.,; ])", "$1Statistical$2")
                .replaceAll("([.,; ])Stn([.,; ])", "$1Station$2")
                .replaceAll("([.,; ])Structure([.,; ])", "$1Structure$2")
                .replaceAll("([.,; ])Struct([.,; ])", "$1Structure$2")
                .replaceAll("([.,; ])Str([.,; ])", "$1Straat$2")
                .replaceAll("([.,; ])St([.,; ])", "$1Street$2")
                .replaceAll("([.,; ])Substance([.,; ])", "$1Substances$2")
                .replaceAll("([.,; ])Subst([.,; ])", "$1Substances$2")
                .replaceAll("([.,; ])Super([.,; ])", "$1Super$2")
                .replaceAll("([.,; ])Surgeon([.,; ])", "$1Surgeons$2")
                .replaceAll("([.,; ])Surg([.,; ])", "$1Surgeons$2")
                .replaceAll("([.,; ])Sw([.,; ])", "$1Southwest$2")
                .replaceAll("([.,; ])Synth([.,; ])", "$1Synthesis$2")
                .replaceAll("([.,; ])System([.,; ])", "$1System$2")
                .replaceAll("([.,; ])Syst([.,; ])", "$1System$2")
                .replaceAll("([.,; ])S([.,; ])", "$1South$2")
                .replaceAll("([.,; ])Tb([.,; ])", "$1Tuberculosis$2")
                .replaceAll("([.,; ])Technical([.,; ])", "$1Technical$2")
                .replaceAll("([.,; ])Technische([.,; ])", "$1Technische$2")
                .replaceAll("([.,; ])Tech([.,; ])", "$1Technical$2")
                .replaceAll("([.,; ])Tel([.,; ])", "$1Telephone$2")
                .replaceAll("([.,; ])Temp([.,; ])", "$1Temperature$2")
                .replaceAll("([.,; ])Terr([.,; ])", "$1Terrestrial$2")
                .replaceAll("([.,; ])Textile([.,; ])", "$1Textiles$2")
                .replaceAll("([.,; ])Text([.,; ])", "$1Textiles$2")
                .replaceAll("([.,; ])Trinid & Tobago([.,; ])", "$1Trinidad & Tobago$2")
                .replaceAll("([.,; ])Tud([.,; ])", "$1Tudomanyos$2")
                .replaceAll("([.,; ])U Arab Emirates([.,; ])", "$1United Arab Emirates$2")
                .replaceAll("([.,; ])Univ([.,; ])", "$1University$2")
                .replaceAll("([.,; ])USA([.,; ])", "$1United States of America$2")
                .replaceAll("([.,; ])Vasc([.,; ])", "$1Vascular$2")
                .replaceAll("([.,; ])Vet([.,; ])", "$1Veterns$2")
                .replaceAll("([.,; ])Weap([.,; ])", "$1Weapons$2")
                .replaceAll("([.,; ])Welf([.,; ])", "$1Welfare$2")
                .replaceAll("([.,; ])Wissenschafter([.,; ])", "$1Wissenschafter$2")
                .replaceAll("([.,; ])Wissenschaftes([.,; ])", "$1Wissenschaftes$2")
                .replaceAll("([.,; ])Wissenschaft([.,; ])", "$1Wissenschaft$2")
                .replaceAll("([.,; ])Wissensch([.,; ])", "$1Wissensch$2")
                .replaceAll("([.,; ])W([.,; ])", "$1West$2")
                .replaceAll("([.,; ])Zent([.,; ])", "$1Zentral$2")
                .replace("(provided by Clarivate Analytics)", "")
                .replace("(provided by Clarivate;-;Analytics)", "")
                .replace("Clarivate Analytics", "")
                .replace("Clarivate", "")
                .replace("Peoples R China", "People's Republic of China")
                .replaceAll("\\[ \\d* \\]", "").replace("\\-\\", "").trim();
        str = reArgsFront(str);
        str = reArgsBack(str);
        return str;
    }

    public static String getStrField(Entity entry, String field) {
        if (null != entry) {
            String str = entry.getStr(field);
            if (null != str && str.length() > 0 && !str.toLowerCase().trim().equals("null")) {
                return str.trim();
            }
        }
        return "";
    }

    public static int getIntField(Entity entry, String field) {
        if (null != entry) {
            Integer num = entry.getInt(field);
            if (null != num && num > 0) {
                return num;
            }
        }
        return 0;
    }

}
